package com.dhcc.DRGsHosp.infra.util.qualitycontrol;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dhcc.DRGsHosp.core.domain.MedicalRecordQuality;
import com.dhcc.DRGsHosp.core.domain.MrDiagnose;
import com.dhcc.DRGsHosp.core.domain.MrOperation;
import com.dhcc.DRGsHosp.core.domain.MrqDictRules;
import com.dhcc.DRGsHosp.core.domain.MrqViolation;
import com.dhcc.DRGsHosp.infra.util.StringUtils;


public class QualityControlMedicalRecord {

    public static Map<String,Map<String,String>> dictionaryMap = new HashMap<>() ;
//    private static final Logger logger = LoggerFactory.getLogger(QualityControlMedicalRecord.class);
    // ========================== 校验规则 Start~ ==========================

    /**
     * Annotation:
     * RULE_CODE: RULE-OrgName
     * RULE_NAME: 医疗机构
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    public void ruleOrgName(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
//        String orgCode = medicalRecordQuality.getBaseInfo().getP00010000();
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00010000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-OrgCode
     * RULE_NAME: 组织机构代码
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    public void ruleOrgCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00010001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-PaymentMode
     * RULE_NAME: 医疗付费方式
     * RULE_INTRODUCTION: 必填项
     * <p>
     * 01	城镇职工基本医疗保险
     * 02	城镇居民基本医疗保险
     * 03	新型农村合作医疗
     * 04	贫困救助
     * 05	商业医疗保险
     * 06	全公费
     * 07	全自费
     * 08	其他社会保险
     * 99	其他
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void rulePaymentMode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        String payment = medicalRecordQuality.getBaseInfo().getP00020001();
        Map<String,String> paymentMap = dictionaryMap.get("paymentMode") ;
        // 是否为空
        if(StringUtils.isBlank(payment)){
            saveViolationInfo(medicalRecordQuality, rule);
            return ;
        }
        // 是否在字典里
        if (!paymentMap.containsKey(payment)) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPTimes
     * RULE_NAME: 第XXX次住院
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIPTimes(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getBaseInfo().getP00040000() == null || medicalRecordQuality.getBaseInfo().getP00040000()<= 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-CaseNo
     * RULE_NAME: 病案号
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleCaseNo(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00050000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Name
     * RULE_NAME: 姓名
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleName(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00060000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Gender01
     * RULE_NAME: 性别-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleGender01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00070001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Gender02
     * RULE_NAME: 性别-2
     * RULE_INTRODUCTION: 当性别为男性时，门（急）诊诊断编码、主要诊断编码、其它诊断编码不能使用以下编码：
     * A34；B37.3；C51-C58；C79.6；D06；D07.0-D07.3；D25-D28；D39；E28；E89.4；F52.5；F53；I86.3；L29.2；M80.0-M80.1；
     * M81.0-M81.1；M83.0；N70-N98；N99.2-N99.3；O00-O99；P54.6；Q50-Q52；R87；S31.4；S37.4-S37.6；T19.2-T19.3；T83.3；
     * Z01.4；Z12.4；Z30.1；Z30.3；Z30.5；Z31.1-Z31.2；Z32-Z37；Z39；Z87.5；Z97.5
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleGender02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        String sexCode = medicalRecordQuality.getBaseInfo().getP00070001();
        String sexDesc = dictionaryMap.get("gender").get(sexCode) ;
        if (!StringUtils.isBlank(sexCode)) {
            if (sexDesc !=null && sexDesc.contains("男")) {
                String[] codes = {
                        "A34", "B37.3", "C51", "C52", "C53", "C54", "C55", "C56", "C57", "C58", // 10
                        "C79.6", "D06", "D07.0", "D07.1", "D07.2", "D07.3", "D25", "D26", "D27", "D28", // 10
                        "D39", "E28", "E89.4", "F52.5", "F53", "I86.3", "L29.2", "M80.0", "M80.1", "M81.0", // 10
                        "M81.1", "M83.0", "N99.2", "N99.3", "P54.6", "Q50", "Q51", "Q52", "R87", "S31.4", // 10
                        "S37.4", "S37.5", "S37.6", "T19.2", "T19.3", "T83.3", "Z01.4", "Z12.4", "Z30.1", "Z30.3", // 10
                        "Z30.5", "Z31.1", "Z31.2", "Z32", "Z33", "Z34", "Z35", "Z36", "Z37", "Z39", // 10
                        "Z87.5", "Z97.5"};
                List<String> codeList = new ArrayList<>(); // 编码集合
                Collections.addAll(codeList, codes);
                // O00-O99
                for (int i = 0; i < 100; i++) {
                    codeList.add("O" + (i / 10 > 0 ? i : "0" + i));
                }
                // N70-N98
                for (int i = 70; i < 99; i++) {
                    codeList.add("N" + i);
                }
                
                List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
                for (MrDiagnose diagnose : diagnoseList) {
                    if (!StringUtils.isBlank(diagnose.getPd0101())) {
                        for (String code : codeList) {
                            if (diagnose.getPd0101().matches(code + ".*")) {
                                saveViolationInfo(medicalRecordQuality, rule);
                                return;
                            }
                        }
                    }
                }
                
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Gender03
     * RULE_NAME: 性别-3
     * RULE_INTRODUCTION: 当性别为女性时，门（急）诊诊断编码、主要诊断编码、其它诊断编码不能使用以下编码：
     * B26.0；C60-C63；D07.4-D07.6；D17.6；D29；D40；E29；E89.5；F52.4；I86.1；L29.1；N40-N51；Q53-Q55；R86；S31.2-S31.3；Z12.5
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleGender03(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        String sexCode = medicalRecordQuality.getBaseInfo().getP00070001();
        String sexDesc = dictionaryMap.get("gender").get(sexCode) ;
        if (!StringUtils.isBlank(sexCode)) {
            if (sexDesc !=null && sexDesc.contains("女")) {
                String[] codes = {
                        "B26.0", "C60", "C61", "C62", "C63", "D07.4", "D07.5", "D07.6", "D17.6", "D29", // 10
                        "D40", "E29", "E89.5", "F52.4", "I86.1", "L29.1", "Q53", "Q54", "Q55", "R86", // 10
                        "S31.2", "S31.3", "Z12.5"}; // 3
                List<String> codeList = new ArrayList<>(); // 编码集合
                Collections.addAll(codeList, codes);
                // N40-N51
                for (int i = 40; i < 52; i++) {
                    codeList.add("N" + i);
                }

                List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
                for (MrDiagnose diagnose : diagnoseList) {
                    if (!StringUtils.isBlank(diagnose.getPd0101())) {
                        for (String code : codeList) {
                            if (diagnose.getPd0101().matches(code + ".*")) {
                                saveViolationInfo(medicalRecordQuality, rule);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Birthday
     * RULE_NAME: 出生日期
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleBirthday(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Age01
     * RULE_NAME: 年龄-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAge01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if ((medicalRecordQuality.getBaseInfo().getP00090000() == null || medicalRecordQuality.getBaseInfo().getP00090000()<= 0)
                && (medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001()<= 0)
                && (medicalRecordQuality.getBaseInfo().getP00090002() == null || medicalRecordQuality.getBaseInfo().getP00090002()<= 0)) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Age02
     * RULE_NAME: 年龄-2
     * RULE_INTRODUCTION: 年龄等于入院日期减出生日期（误差范围1岁）
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAge02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        Date birthday, inDate;
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) {
            return;
        } else {
            birthday = medicalRecordQuality.getBaseInfo().getP00080000();
        }
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) {
            return;
        } else {
            inDate = medicalRecordQuality.getIpinfo().getP00250000();
        }


        // 计算年龄 = 入院日期-出生日期
        int age = getAge(birthday,inDate);
        if (medicalRecordQuality.getBaseInfo().getP00090000() != null && medicalRecordQuality.getBaseInfo().getP00090000() > 0) {
            int ageYear = medicalRecordQuality.getBaseInfo().getP00090000();
            if (Math.abs(ageYear - age) > 1) {
                saveViolationInfo(medicalRecordQuality, rule);
                return;
            }
        }
        
        //年龄（月）
        int days=differentDays(birthday,inDate);
        if (medicalRecordQuality.getBaseInfo().getP00090001() != null && medicalRecordQuality.getBaseInfo().getP00090001() > 0) {
            long ageMonth = medicalRecordQuality.getBaseInfo().getP00090001().longValue();
            if (Math.abs(ageMonth * 30 - days) > 365) {
                saveViolationInfo(medicalRecordQuality, rule);
                return;
            }
        }
        //年龄（天）
        if (medicalRecordQuality.getBaseInfo().getP00090002() != null && medicalRecordQuality.getBaseInfo().getP00090002() > 0) {
            long ageDays = medicalRecordQuality.getBaseInfo().getP00090002().longValue();
            if (Math.abs(ageDays - days) > 365) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AgeMonth01
     * RULE_NAME: 不足一周岁年龄（月天）-1
     * RULE_INTRODUCTION: 当门（急）诊诊断编码、主要诊断编码、其它诊断编码出现P10～P15时，入院日期减出生日期必须≤28天，且（年龄不足1周岁的）年龄必须≤28天，
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAgeMonth01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            String diagCode = diagnose.getPd0101();
            if (!StringUtils.isBlank(diagCode) && diagCode.matches("P1[0-5].*")) {
                // 不足一周岁
                if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getBaseInfo().getP00080000() != null) {
                    if ((medicalRecordQuality.getBaseInfo().getP00090002() == null || medicalRecordQuality.getBaseInfo().getP00090002()<= 0)
                            || (medicalRecordQuality.getBaseInfo().getP00090000() != null && medicalRecordQuality.getBaseInfo().getP00090000() != 0)
                            || (medicalRecordQuality.getBaseInfo().getP00090001() != null && medicalRecordQuality.getBaseInfo().getP00090001() != 0)) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    } else {
                        long days = (medicalRecordQuality.getIpinfo().getP00250000().getTime() - medicalRecordQuality.getBaseInfo().getP00080000().getTime()) / 1000 / 60 / 60 / 24;
                        int ageDays = medicalRecordQuality.getBaseInfo().getP00090002().intValue();
                        if (!(days <= 28 && days > 0 && ageDays <= 28 && ageDays > 0)) {
                            saveViolationInfo(medicalRecordQuality, rule);
                            return;
                        }
                    }
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AgeMonth02
     * RULE_NAME: 不足一周岁年龄（月天）-2
     * RULE_INTRODUCTION: 年龄小于1周岁即年龄为0时，（年龄不足1周岁的）年龄不能为空
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAgeMonth02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getBaseInfo().getP00090000() != null && medicalRecordQuality.getBaseInfo().getP00090000() == 0) {
            if ((medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001() == 0)
                    && (medicalRecordQuality.getBaseInfo().getP00090002() == null || medicalRecordQuality.getBaseInfo().getP00090002() == 0)) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Nationality
     * RULE_NAME: 国籍
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleNationality(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00100000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }




    /**
     * Annotation:
     * RULE_CODE: RULE-BirthWeight
     * RULE_NAME: 新生儿出生体重（可能多胎）
     * RULE_INTRODUCTION: 一定条件下必填，当其它诊断编码为Z37，或（年龄不足1周岁的）年龄≤28天，或入院日期减出生日期≤28天时，新生儿出生体重不能为空
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleBirthWeight(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 1. 当其他诊断编码为Z37时，新生儿出生体重为必填项
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if (!StringUtils.isBlank(diagnose.getPd0101())) {
                if (diagnose.getPd0101().matches("Z37.*") && "O".equals(diagnose.getPdType())) {
                    if (medicalRecordQuality.getBaseInfo().getP00110000() == null || medicalRecordQuality.getBaseInfo().getP00110000()<= 0) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }

        // 2. （年龄不足1周岁的）年龄≤28天，新生儿出生体重为必填项
        // 年龄(天)有值 && 年龄(年)和年龄(月)没有值或是0
        if (medicalRecordQuality.getBaseInfo().getP00090002() != null && (medicalRecordQuality.getBaseInfo().getP00090000() == null || medicalRecordQuality.getBaseInfo().getP00090000() == 0)
                && (medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001() == 0)) {
            int ageDays = medicalRecordQuality.getBaseInfo().getP00090002();
            if (ageDays > 0 && ageDays <= 28) {
                if (medicalRecordQuality.getBaseInfo().getP00110000() == null || medicalRecordQuality.getBaseInfo().getP00110000()<= 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }

        // 3. 入院日期减出生日期≤28天时，新生儿出生体重为必填项
        Date birthday, inDate;
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) { // 出生日期为空则不校验
            return;
        } else {
            birthday = medicalRecordQuality.getBaseInfo().getP00080000();
        }
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) { // 入院日期不校验
            return;
        } else {
            inDate = medicalRecordQuality.getIpinfo().getP00250000();
        }

//        double days = Math.ceil(CommonUtils.div(CommonUtils.sub(inDate.getTime(), birthday.getTime()), DENOMINATOR_DAYS));
        int days = differentDays(birthday,inDate) ;
        if (days <= 28 && days > 0) {
            if (medicalRecordQuality.getBaseInfo().getP00110000() == null || medicalRecordQuality.getBaseInfo().getP00110000()<= 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPWeight
     * RULE_NAME: 新生儿入院体重
     * RULE_INTRODUCTION: 一定条件下必填，（年龄不足1周岁的）年龄≤28天，或入院日期减出生日期≤28天时，新生儿入院体重不能为空
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIPWeight(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 1. （年龄不足1周岁的）年龄≤28天，新生儿入院体重为必填项
        // 年龄(天)有值 && 年龄(年)和年龄(月)没有值或是0
        if (medicalRecordQuality.getBaseInfo().getP00090002() != null && (medicalRecordQuality.getBaseInfo().getP00090000() == null || medicalRecordQuality.getBaseInfo().getP00090000() == 0)
                && (medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001() == 0)) {
            int ageDays = medicalRecordQuality.getBaseInfo().getP00090002();
            if (ageDays > 0 && ageDays <= 28) {
                if (medicalRecordQuality.getBaseInfo().getP00120000() == null || medicalRecordQuality.getBaseInfo().getP00120000()<= 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }

        // 2. 入院日期减出生日期≤28天时，新生儿入院体重为必填项
        Date birthday, inDate;
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) {
            return;
        } else {
            birthday = medicalRecordQuality.getBaseInfo().getP00080000();
        }
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) {
            return;
        } else {
            inDate = medicalRecordQuality.getIpinfo().getP00250000();
        }

        int days = differentDays(inDate,birthday) ;
        if (days <= 28 && days > 0) {
            if (medicalRecordQuality.getBaseInfo().getP00120000() == null || medicalRecordQuality.getBaseInfo().getP00120000()<= 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /** 
     * Annotation:
     * RULE_CODE: RULE-Birthplace
     * RULE_NAME: 出生地（省、市、县）
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleBirthplace(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130100()) && 
        		StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130200())&& StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130300())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-NativePlace
     * RULE_NAME: 籍贯
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleNativePlace(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140100()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Nation
     * RULE_NAME: 民族
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleNation(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
//        String nation =  dictionaryMap.get("nation").get(medicalRecordQuality.getBaseInfo().getP00150000()) ;
//        String nation =  medicalRecordQuality.getBaseInfo().getP00150000() ;
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00150000())) {
            // 没有或不在字典之中
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IDNo
     * RULE_NAME: 身份证号
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIDNo(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00160000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Career
     * RULE_NAME: 职业
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleCareer(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00170000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /** ??? 是否使用编码
     * Annotation:
     * RULE_CODE: RULE-Marriage
     * RULE_NAME: 婚姻
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleMarriage(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00180000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Address
     * RULE_NAME: 现住址（省、市、县、街道）
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAddress(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190100()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190200())
                && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190300()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190400())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Telephone
     * RULE_NAME: 现住址电话
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleTelephone(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190500())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ZipCode
     * RULE_NAME: 现住址邮编
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleZipCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190600())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-RegisteredAddress
     * RULE_NAME: 户口地址（省、市、县、街道）
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleRegisteredAddress(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200100()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200200())
                && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200300()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200400())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-RegisteredZipCode
     * RULE_NAME: 户口地址邮编
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleRegisteredZipCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200500())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-UnitAddress
     * RULE_NAME: 工作单位及地址
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleUnitAddress(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00210000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-UnitTelephone
     * RULE_NAME: 工作单位电话
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleUnitTelephone(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00210100())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-UnitZipCode
     * RULE_NAME: 工作单位邮编
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleUnitZipCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00210200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ContactName
     * RULE_NAME: 联系人姓名
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleContactName(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Relationship
     * RULE_NAME: 联系人关系
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleRelationship(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220100())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ContactAddress
     * RULE_NAME: 联系人地址
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleContactAddress(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ContactTelephone
     * RULE_NAME: 联系人电话
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleContactTelephone(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220300())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HealthCardNo
     * RULE_NAME: 健康卡号
     * RULE_INTRODUCTION: 有：填写健康卡号或就医卡号，无：划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleHealthCardNo(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00030000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionModeCode
     * RULE_NAME: 入院途径编码
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionModeCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00230001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionModeDesc
     * RULE_NAME: 入院途径描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionModeDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00230000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDate01
     * RULE_NAME: 入院时间-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionDate01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDate02
     * RULE_NAME: 入院时间-2
     * RULE_INTRODUCTION: 入院日期≤出院日期
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionDate02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            // 如果入院日期大于出院日期
            if (inDate!=null && outDate!= null && inDate.compareTo(outDate) > 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDate03
     * RULE_NAME: 入院时间-3
     * RULE_INTRODUCTION: 入院日期≤手术操作日期
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionDate03(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	//因为手术操作日期精确到日2019-01-01，入院日期精确到分2019-01-01 15:16:00，所以不能用compareTo进行比较
                Date operDate = mrOperation.getPo0200();
                if (inDate != null && operDate!= null && differentDays(operDate,inDate) > 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    break;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDepCode
     * RULE_NAME: 入院科别编码
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionDepCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00260001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDepDesc
     * RULE_NAME: 入院科别描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionDepDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00260000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionWardCode
     * RULE_NAME: （入院）病房编码
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionWardCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00270001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionWardDesc
     * RULE_NAME: （入院）病房编描述
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionWardDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00270000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }


    /**
     * Annotation:
     * RULE_CODE: RULE-TransferDep
     * RULE_NAME: 转科科别
     * RULE_INTRODUCTION: 入院科别 <> 出院科别 的情况下才填入转科科别
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleTransferDep(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!isBlankCode(medicalRecordQuality.getIpinfo().getP00260001()) && !isBlankCode(medicalRecordQuality.getIpinfo().getP00300001()) &&
                !medicalRecordQuality.getIpinfo().getP00260001().equals(medicalRecordQuality.getIpinfo().getP00300001()))
            // 转科科别
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00280001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDate01
     * RULE_NAME: 出院时间-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeDate01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00290000() == null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDate02
     * RULE_NAME: 出院时间-2
     * RULE_INTRODUCTION: 入院日期≤出院日期
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeDate02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            if (inDate!=null && outDate!=null && inDate.compareTo(outDate) > 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDate03
     * RULE_NAME: 出院时间-3
     * RULE_INTRODUCTION: 入院日期≤手术操作日期≤出院日期
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeDate03(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) { // 获取一个病案的最早的手术日期
                Date operDate = mrOperation.getPo0200();
              //因为手术操作日期精确到日2019-01-01，入院日期精确到分2019-01-01 15:16:00，所以不能用compareTo进行比较
                if (operDate != null && inDate!=null && outDate!=null 
                	&& !(differentDays(inDate,operDate) >= 0 && differentDays(operDate,outDate) >= 0)) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    break;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDepCode
     * RULE_NAME: 出院科别编码
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeDepCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00300001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDepDesc
     * RULE_NAME: 出院科别描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeDepDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00300000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeWardCode
     * RULE_NAME: （出院）病房编码
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeWardCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00310001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

      /**
     * Annotation:
     * RULE_CODE: RULE-DischargeWardDesc
     * RULE_NAME: （出院）病房描述
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeWardDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00310000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-InpatientDays
     * RULE_NAME: 实际住院天数
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleInpatientDays(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00320000() == null || medicalRecordQuality.getIpinfo().getP00320000()<= 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-CaseQualityDesc
     * RULE_NAME: 病案质量描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleCaseQualityDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-CaseQualityCode
     * RULE_NAME: 病案质量编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleCaseQualityCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicDiagnosisDescribe
     * RULE_NAME: 门急诊诊断描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleClinicDiagnosisDescribe(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00940001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicDiagnosisCode
     * RULE_NAME: 门急诊诊断编码
     * RULE_INTRODUCTION: 必填项
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleClinicDiagnosisCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00940002()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicDiagnosis
     * RULE_NAME: 门急诊诊断编码
     * RULE_INTRODUCTION: 编码范围应为：A～U开头和Z开头的编码；不包括字母V、W、X、Y开头的编码
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleClinicDiagnosis(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00940002())) {
            String opDiagnosisCode = medicalRecordQuality.getIpinfo().getP00940002();

//            if (opDiagnosisCode.matches(DASH_REGEX_STR)) return; // 病案首页允许录入短横线代表空，此时不算违规
            if(StringUtils.hasLength(opDiagnosisCode)){
                if (!(opDiagnosisCode.substring(0, 1).matches("[A-U]") || "Z".equals(opDiagnosisCode.substring(0, 1)))) {
                    saveViolationInfo(medicalRecordQuality, rule);
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherDiagnosisDesc
     * RULE_NAME: （其他出院诊断）描述
     * RULE_INTRODUCTION: 必填，每个1分
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOtherDiagnosisDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("O".equals(diagnose.getPdType())) {
                if (isBlankDesc(diagnose.getPd0100())) {
                	saveViolationInfo(medicalRecordQuality, rule);
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherDiagnosis01
     * RULE_NAME: （其他出院诊断）编码-1
     * RULE_INTRODUCTION: 编码范围应为：A～U开头和Z开头的编码；不包括字母V、W、X、Y开头的编码
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOtherDiagnosis01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("O".equals(diagnose.getPdType())) {
                String diagCode = diagnose.getPd0101();
                if (!isBlankCode(diagCode)) {
                    if (!(diagCode.substring(0, 1).matches("[A-U]") || "Z".equals(diagCode.substring(0, 1)))) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-OtherDiagnosis02
     * RULE_NAME: （其他出院诊断）编码-2
     * RULE_INTRODUCTION: 当主要诊断或者其它诊断编码出现O80-O84编码，且无流产结局编码出现O00-O08编码时，其它诊断编码必须有分娩结局编码Z37
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOtherDiagnosis02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        List<String> diagCodes = new ArrayList<>();
        List<String> otherDiagCodes = new ArrayList<>();
        for (MrDiagnose diagnose : diagnoseList) {
            diagCodes.add(diagnose.getPd0101());
            if ("O".equals(diagnose.getPdType())) {
                otherDiagCodes.add(diagnose.getPd0101());
            }
        }

        boolean flag1 = false;
        boolean flag2 = true;
        for (String diagCode : diagCodes) {
            if (!isBlankCode(diagCode) && diagCode.matches("O8[0-4].*")) {
                flag1 = true;
                break;
            }
        }
        for (String diagCode : diagCodes) {
            if (!isBlankCode(diagCode) && diagCode.matches("O0[0-8].*")) {
                flag2 = false;
                break;
            }
        }
        if (flag1 && flag2) {
            for (String otherDiagCode : otherDiagCodes) {
                if (!isBlankCode(otherDiagCode) && otherDiagCode.matches("Z37.*")) {
                    return;
                }
            }
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherSurseryName
     * RULE_NAME: （其他手术）名称
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherSurseryName(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&isBlankDesc(mrOperation.getPo0100())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherOperationName
     * RULE_NAME: （其他操作）名称
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherOperationName(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&isBlankDesc(mrOperation.getPo0100())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherSurseryCode
     * RULE_NAME: （其他手术）编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherSurseryCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&isBlankCode(mrOperation.getPo0101())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherOperationCode
     * RULE_NAME: （其他操作）编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherOperationCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&isBlankCode(mrOperation.getPo0101())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SectionHead
     * RULE_NAME: 科主任
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对科主任未要求编码字典，故此处只校验文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSectionHead(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600101())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Archiater
     * RULE_NAME: 主任（副主任）医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleArchiater(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600201())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Physician
     * RULE_NAME: 主治医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void rulePhysician(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600301())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Resident
     * RULE_NAME: 住院医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleResident(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600401())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Attending
     * RULE_NAME: 主诊医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAttending(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        String attendingCode = medicalRecordQuality.getIpinfo().getP00601001();
        if(isBlankCode(attendingCode)) {
            saveViolationInfo(medicalRecordQuality,rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InternDoctor
     * RULE_NAME: 实习医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleInternDoctor(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if(isBlankCode(medicalRecordQuality.getIpinfo().getP00600800())) {
            saveViolationInfo(medicalRecordQuality,rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdvancedDoctor
     * RULE_NAME: 进修医师
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleAdvancedDoctor(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00600600())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-QCDoctor
     * RULE_NAME: 质控医师
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleQCDoctor(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610100())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-QCNurse
     * RULE_NAME: 质控护士
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleQCNurse(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-QCDate
     * RULE_NAME: 质控日期
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleQCDate(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (null == medicalRecordQuality.getIpinfo().getP00610300() ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ChargeNurse
     * RULE_NAME: 责任护士
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对护士未要求编码字典，故此处只校验文字信息
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleChargeNurse(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00600500())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnosisDescribe
     * RULE_NAME: （主要出院诊断）名称
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDiagnosisDescribe(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
            for (MrDiagnose diagnose : diagnoseList) {
                String diagnoseTypeMain = diagnose.getPdType() ;
                // 判断是否是主诊断
                if("M".equals(diagnoseTypeMain)){
                    if (StringUtils.isBlank(diagnose.getPd0100()) ) {
                        saveViolationInfo(medicalRecordQuality, rule);
                    }
                }
            }
    	}else if(medicalRecordQuality.getDiagnose().isEmpty()){
    		saveViolationInfo(medicalRecordQuality, rule);
    	} 
    	
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Diagnosis
     * RULE_NAME: （主要出院诊断）编码
     * RULE_INTRODUCTION: 编码范围应为：A～U开头和Z开头的编码；不包括字母V、W、X、Y开头的编码
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDiagnosis(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
            for (MrDiagnose diagnose : diagnoseList) {
                String diagnoseCodeMain = diagnose.getPd0101() ;
                String diagnoseTypeMain = diagnose.getPdType() ;
                if("M".equals(diagnoseTypeMain)) {
                    if (!(diagnoseCodeMain.substring(0, 1).matches("[A-U]") || "Z".equals(diagnoseCodeMain.substring(0, 1)))) {
                        saveViolationInfo(medicalRecordQuality, rule);
                    }
                }
            }
    	}
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionConditionDesc
     * RULE_NAME: （主要出院诊断）入院病情描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionConditionDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("M".equals(diagnose.getPdType())) {
                if (StringUtils.isBlank(diagnose.getPd0200())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionConditionCode
     * RULE_NAME: （主要出院诊断）入院病情编码
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionConditionCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("M".equals(diagnose.getPdType())) {
                if (StringUtils.isBlank(diagnose.getPd0201())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Efficacy01
     * RULE_NAME: （主要出院诊断）疗效-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleEfficacy01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> mrDiagnoseList = medicalRecordQuality.getDiagnose() ;
        for (MrDiagnose mrDiagnose : mrDiagnoseList) {
            if ("M".equals(mrDiagnose.getPdType())) {
                if (StringUtils.isBlank(mrDiagnose.getPd0202())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Efficacy02
     * RULE_NAME: （主要出院诊断）疗效-2
     * RULE_INTRODUCTION: 有“尸体料理费”的患者，“疗效”只能为“死亡”
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleEfficacy02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // TODO T_MEDICALRECORD 表中无此字段——（主要出院诊断）疗效-2 标准病案无此项
        List<MrDiagnose> mrDiagnoseList = medicalRecordQuality.getDiagnose() ;
//        for (MrDiagnose mrDiagnose : mrDiagnoseList) {
//           String diagTypeCode = mrDiagnose.getPdType();
//            if ("M".equals(diagTypeCode)) {
//                if (!"死亡".equals(mrDiagnose.getPd0202())) {
//                    saveViolationInfo(medicalRecordQuality, rule);
//                   return;
//                }
//            }
//        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-InjuryAndPoisingDescribeDesc
     * RULE_NAME: 损伤中毒的外部原因描述
     * RULE_INTRODUCTION: 必填项
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleInjuryAndPoisingDescribeDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00900000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InjuryAndPoisingDescribeCode
     * RULE_NAME: 损伤中毒的外部原因编码
     * RULE_INTRODUCTION: 必填项
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleInjuryAndPoisingDescribeCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00900001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InjuryAndPoising
     * RULE_NAME: 损伤中毒的外部原因编码
     * RULE_INTRODUCTION: ICD-10编码范围：V、W、X、Y开头的，或者-
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleInjuryAndPoising(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00900001())) {
            String damagePoisonIcdCd = medicalRecordQuality.getIpinfo().getP00900001();
//            if (damagePoisonIcdCd.matches(DASH_REGEX_STR)) return;
            if (damagePoisonIcdCd.matches("^[-—]+$")) {//如果是多个-或中文—不违规
            }else if (!"V,W,X,Y".contains(damagePoisonIcdCd.substring(0, 1))) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        } else {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Pathology
     * RULE_NAME: 病理号（有一次住院多个标本的可能）
     * RULE_INTRODUCTION: 必填项
     * PS: 即使不做病理，也应该录入 - （短横线）
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void rulePathology(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400100())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-PathologicalDiagnosisDesc
     * RULE_NAME: 病理诊断描述
     * RULE_INTRODUCTION: 必填项
     * PS: 即使不做病理，也应该录入 - （短横线）
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void rulePathologicalDiagnosisDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400101())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PathologicalDiagnosisCode
     * RULE_NAME: 病理诊断编码
     * RULE_INTRODUCTION: 必填项
     * PS: 即使不做病理，也应该录入 - （短横线）
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void rulePathologicalDiagnosisCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400401())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SevereCase
     * RULE_NAME: 急危重病例  P00910000
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSevereCase(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00910000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DrugAllergy
     * RULE_NAME: 有无药物过敏
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDrugAllergy(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00510000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AllergicDrug
     * RULE_NAME: 过敏药物
     * RULE_INTRODUCTION: 一定条件下必填，患者有药物过敏，则过敏药物必填。
     * PS: 1-无   2-有
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAllergicDrug(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 1无；2有
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00510000()) && "2".equals(medicalRecordQuality.getIpinfo().getP00510000())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00520000())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Autopsy
     * RULE_NAME: 死亡患者是否尸检
     * RULE_INTRODUCTION: 一定条件下必填，有“尸体料理费”的患者，“离院方式”或“疗效”为“死亡”的患者，“死亡患者尸检”必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAutopsy(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 标准病案首页无“尸体料理费”，只校验离院方式
        if ("5".equals(medicalRecordQuality.getIpinfo().getP00620001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00530000())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-BloodTypeCode
     * RULE_NAME: ABO血型编码
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleBloodTypeCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00570001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

      /**
     * Annotation:
     * RULE_CODE: RULE-BloodTypeDesc
     * RULE_NAME: ABO血型描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleBloodTypeDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00570000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-RhCode
     * RULE_NAME: Rh血型编码
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleRhCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00580001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-RhDesc
     * RULE_NAME: Rh血型描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleRhDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00580000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }


    /** ???
     * Annotation:
     * RULE_CODE: RULE-SurgeryDate
     * RULE_NAME: （主要手术）日期
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurgeryDate(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&mrOperation.getPo0200() == null) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-SurgeryNameDesc
     * RULE_NAME: （主要手术）名称描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurgeryNameDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0100())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurgeryNameCode
     * RULE_NAME: （主要手术）名称编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurgeryNameCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0101())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryLevelDesc
     * RULE_NAME: （主要手术）级别描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryLevelDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0300())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryLevelCode
     * RULE_NAME: （主要手术）级别编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryLevelCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0301())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurserySurgeonDesc
     * RULE_NAME: （主要手术）术者描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurserySurgeonDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankDesc(mrOperation.getPo0400())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }            		
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationDoctorDesc
     * RULE_NAME: （主要手术）医师描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationDoctorDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankDesc(mrOperation.getPo0400())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }            		
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurserySurgeonCode
     * RULE_NAME: （主要手术）术者编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurserySurgeonCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankCode(mrOperation.getPo0401())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }            		
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationDoctorCode
     * RULE_NAME: （主要手术）医师编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationDoctorCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
	                if ( StringUtils.isBlank(mrOperation.getPo0401())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIAssistantDesc
     * RULE_NAME: （主要手术）Ⅰ助描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryIAssistantDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankDesc(mrOperation.getPo0500())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIAssistantCode
     * RULE_NAME: （主要手术）Ⅰ助编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryIAssistantCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankCode(mrOperation.getPo0501())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIIAssistantDesc
     * RULE_NAME: （主要手术）Ⅱ助描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryIIAssistantDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankDesc(mrOperation.getPo0600()) ) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIIAssistantCode
     * RULE_NAME: （主要手术）Ⅱ助编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryIIAssistantCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankCode(mrOperation.getPo0601())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIncisionHealingLevelDesc
     * RULE_NAME: （主要手术）切口愈合等级描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryIncisionHealingLevelDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0800())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIncisionHealingLevelCode
     * RULE_NAME: （主要手术）切口愈合等级编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryIncisionHealingLevelCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0801())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryAnesthesiaDesc
     * RULE_NAME: （主要手术）麻醉方式描述
     * RULE_INTRODUCTION: 有“麻醉费”的患者，麻醉方式必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryAnesthesiaDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0700())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryAnesthesiaCode
     * RULE_NAME: （主要手术）麻醉方式编码
     * RULE_INTRODUCTION: 有“麻醉费”的患者，麻醉方式必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryAnesthesiaCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0701())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryAnesthetistDesc
     * RULE_NAME: （主要手术）麻醉医师描述
     * RULE_INTRODUCTION: 有“麻醉费”的患者，麻醉医师必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryAnesthetistDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
	                if (StringUtils.isBlank(mrOperation.getPo0900()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryAnesthetistCode
     * RULE_NAME: （主要手术）麻醉医师编码
     * RULE_INTRODUCTION: 有“麻醉费”的患者，麻醉医师必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleSurseryAnesthetistCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
	                if ( StringUtils.isBlank(mrOperation.getPo0901())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationDate
     * RULE_NAME: （主要操作）日期
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationDate(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&mrOperation.getPo0200() == null) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-OperationNameDesc
     * RULE_NAME: （主要操作）名称描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationNameDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0100())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationNameCode
     * RULE_NAME: （主要操作）名称编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationNameCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0101())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationLevelDesc
     * RULE_NAME: （主要操作）级别描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationLevelDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0300())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationLevelCode
     * RULE_NAME: （主要操作）级别编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationLevelCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0301())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationSurgeonDesc
     * RULE_NAME: （主要操作）术者描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationSurgeonDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (isBlankDesc(mrOperation.getPo0400()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationSurgeonCode
     * RULE_NAME: （主要操作）术者编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationSurgeonCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (isBlankCode(mrOperation.getPo0401())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationOperationDoctor
     * RULE_NAME: （主要操作）医师描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationOperationDoctorDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (StringUtils.isBlank(mrOperation.getPo0400()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationOperationDoctor
     * RULE_NAME: （主要操作）医师编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationOperationDoctorCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if ( StringUtils.isBlank(mrOperation.getPo0401())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIAssistantDesc
     * RULE_NAME: （主要操作）Ⅰ助描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationIAssistantDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (isBlankDesc(mrOperation.getPo0500()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIAssistantCode
     * RULE_NAME: （主要操作）Ⅰ助编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationIAssistantCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (isBlankCode(mrOperation.getPo0501())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIIAssistantDesc
     * RULE_NAME: （主要操作）Ⅱ助描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationIIAssistantDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (isBlankDesc(mrOperation.getPo0600()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIIAssistantCode
     * RULE_NAME: （主要操作）Ⅱ助编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationIIAssistantCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (isBlankCode(mrOperation.getPo0601())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIncisionHealingLevelDesc
     * RULE_NAME: （主要操作）切口愈合等级描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationIncisionHealingLevelDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0800())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIncisionHealingLevelCode
     * RULE_NAME: （主要操作）切口愈合等级编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationIncisionHealingLevelCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0801())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationAnesthesiaDesc
     * RULE_NAME: （主要操作）麻醉方式描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationAnesthesiaDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0700())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationAnesthesiaCode
     * RULE_NAME: （主要操作）麻醉方式编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationAnesthesiaCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0701())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationAnesthetistDesc
     * RULE_NAME: （主要操作）麻醉医师描述
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationAnesthetistDesc(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if (StringUtils.isBlank(mrOperation.getPo0900()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationAnesthetistCode
     * RULE_NAME: （主要操作）麻醉医师编码
     * RULE_INTRODUCTION: 有“影像学诊断费”的患者，必填。
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleOperationAnesthetistCode(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())){
	                if ( StringUtils.isBlank(mrOperation.getPo0901())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeMode01
     * RULE_NAME: 离院方式-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeMode01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeMode02
     * RULE_NAME: 离院方式-2
     * RULE_INTRODUCTION: 有“尸体料理费”的患者，“离院方式”都只能为“死亡”
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleDischargeMode02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // T_MEDICALRECORD 中无“尸体料理费”字段 标准病案无此项
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalTransferReceptionUnit
     * RULE_NAME: 医嘱转院接收单位
     * RULE_INTRODUCTION: 一定条件下必填，医嘱转院，该项必填
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleHospitalTransferReceptionUnit(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620001()) && "2".equals(medicalRecordQuality.getIpinfo().getP00620001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620100())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-CommunityTransferReceptionUnit
     * RULE_NAME: 医嘱转社区等医疗机构接收单位
     * RULE_INTRODUCTION: 一定条件下必填，医嘱转社区卫生服务机构/乡镇卫生院，该项必填
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleCommunityTransferReceptionUnit(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    	if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620001()) && "3".equals(medicalRecordQuality.getIpinfo().getP00620001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620200())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Coder
     * RULE_NAME: 编码员
     * RULE_INTRODUCTION: 必填项
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 09/03/2018 4:44 PM
     */
    private void ruleCoder(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00600900())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IsInner31Days
     * RULE_NAME: 是否有31天内再次入院计划
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIsInner31Days(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00630001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    
    /**
     * Annotation:
     * RULE_CODE: RULE-Inner31DaysPurpose
     * RULE_NAME: 31天内再次入院目的
     * RULE_INTRODUCTION: 一定条件下必填，有31天内再入院计划的患者，再次住院目的，必填。
     * PS: 1-无   2-有
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleInner31DaysPurpose(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if ("2".equals(medicalRecordQuality.getIpinfo().getP00630001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00630100())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-BeforeCraniocerebralTrauma
     * RULE_NAME: （入院前）颅脑损伤时间
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleBeforeCraniocerebralTrauma(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AfterCraniocerebralTrauma
     * RULE_NAME: （入院后）颅脑损伤时间
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAfterCraniocerebralTrauma(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUName
     * RULE_NAME: （重症监护室）名称 P00930000
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleICUName(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00930000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUInDate01
     * RULE_NAME: （重症监护室）进入时间-1  P00930001
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleICUInDate01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00930000())) {
            if(medicalRecordQuality.getIpinfo().getP00930001() == null ){
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUInDate02
     * RULE_NAME: （重症监护室）进入时间-2
     * RULE_INTRODUCTION: 入院日期≤监护室进入时间≤监护室退出时间≤出院日期
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleICUInDate02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            //因为监护室进入时间、监护室退出时间都是精确到日2019-01-01，入院日期精确到分2019-01-01 15:16:00，所以不能用compareTo进行比较
            Date inIcuDate = medicalRecordQuality.getIpinfo().getP00930001();
            Date outIcuDate = medicalRecordQuality.getIpinfo().getP00930002() ;
            if (inIcuDate != null && inDate!=null && outDate!=null && outIcuDate!=null
            		&& !(differentDays(inDate,inIcuDate) >= 0 && differentDays(inIcuDate,outIcuDate) >= 0 && differentDays(outIcuDate,outDate)>=0)) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUOutDate01
     * RULE_NAME: （重症监护室）转出时间-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleICUOutDate01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00930000())) {
            if(medicalRecordQuality.getIpinfo().getP00930002() == null ){
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUOutDate02
     * RULE_NAME: （重症监护室）转出时间-2
     * RULE_INTRODUCTION: 入院日期≤监护室进入时间≤监护室退出时间≤出院日期
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleICUOutDate02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            Date inIcuDate = medicalRecordQuality.getIpinfo().getP00930001();
            Date outIcuDate = medicalRecordQuality.getIpinfo().getP00930002();
            if (inIcuDate != null && inDate!=null && outDate!=null && outIcuDate!=null
            		&& !(differentDays(inDate,inIcuDate) >= 0 && differentDays(inIcuDate,outIcuDate) >= 0 && differentDays(outIcuDate,outDate)>=0)) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-VentilatorUsageTime
     * RULE_NAME: 呼吸机使用时间
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleVentilatorUsageTime(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getMrAppendPage().getP90120201() == null || medicalRecordQuality.getMrAppendPage().getP90120201()<0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }


    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts01
     * RULE_NAME: 住院总费用-1
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIPCosts01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() == null || medicalRecordQuality.getIpinfo().getP00800000()<= 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts02
     * RULE_NAME: 住院总费用-2
     * RULE_INTRODUCTION: 费用不能小于5，不能大于1000000
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIPCosts02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() != null) {
            double costAmount = medicalRecordQuality.getIpinfo().getP00800000().doubleValue();
            if (costAmount < 5 || costAmount > 1000000) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }else{
        	saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts03
     * RULE_NAME: 住院总费用-3
     * RULE_INTRODUCTION: 分项费用全部有值时，住院总费用应等于各分项费用（除自付金额,临床物理治疗费,麻醉费,手术费,抗菌药物费用外）之和。
     * P782=P752+P754+P755+P756+P757+P758+P759+P760+P761+P763+P767+P768+P769+P771+P772+P773+P774+P775+P776+P777+P778+P779+P780+P781
     * <p>
     * 住院总费用（P782）
     * 一般医疗服务费（P752）
     * 一般治疗操作费（P754）
     * 护理费（P755）
     * 综合医疗服务类其他费用（P756）
     * 病理诊断费（P757）
     * 实验室诊断费（P758）
     * 影像学诊断费（P759）
     * 临床诊断项目费（P760）
     * 非手术治疗项目费（P761）
     * 手术治疗费（P763）
     * 康复费（P767）
     * 中医治疗费（P768）
     * 西药费（P769）
     * 中成药费（P771）
     * 中草药费（P772）
     * 血费（P773）
     * 白蛋白类制品费（P774）
     * 球蛋白类制品费（P775）
     * 凝血因子类制品费（P776）
     * 细胞因子类制品费（P777）
     * 检查用一次性医用材料费（P778）
     * 治疗用一次性医用材料费（P779）
     * 手术用一次性医用材料费（P780）
     * 其他费（P781）
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIPCosts03(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() != null) {//住院总费用
        	
            if ((medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") != null && medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") > 0) // 一般医疗服务费（P752）
                    && (medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") != null && medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") > 0) // 一般治疗操作费（P754）
                    && (medicalRecordQuality.getExpenseMap().get("huLif") != null && medicalRecordQuality.getExpenseMap().get("huLif") > 0) // 护理费（P755）
                    && (medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") != null && medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") > 0) // 综合医疗服务类其他费用（P756）
                    && (medicalRecordQuality.getExpenseMap().get("bingLizdf") != null && medicalRecordQuality.getExpenseMap().get("bingLizdf") >0) // 病理诊断费（P757）
                    && (medicalRecordQuality.getExpenseMap().get("shiYanShizdf") != null && medicalRecordQuality.getExpenseMap().get("shiYanShizdf") > 0) // 实验室诊断费（P758）
                    && (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) // 影像学诊断费（P759）
                    && (medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") > 0) // 临床诊断项目费（P760）
                    && (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") > 0) // 非手术治疗项目费（P761）
                    && (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) // 手术治疗费（P763）
                    && (medicalRecordQuality.getExpenseMap().get("kangFuf") != null && medicalRecordQuality.getExpenseMap().get("kangFuf") > 0) // 康复费（P767）
                    && (medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") != null && medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") > 0) // 中医治疗费（P768）
                    && (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("xiYaof") > 0) // 西药费（P769）
                    && (medicalRecordQuality.getExpenseMap().get("zhongChengYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongChengYaof") > 0) // 中成药费（P771）
                    && (medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") > 0) // 中草药费（P772）
                    && (medicalRecordQuality.getExpenseMap().get("xuef") != null && medicalRecordQuality.getExpenseMap().get("xuef") > 0) // 血费（P773）
                    && (medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") > 0) // 白蛋白类制品费（P774）
                    && (medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") > 0) // 球蛋白类制品费（P775）
                    && (medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") > 0) // 凝血因子类制品费（P776）
                    && (medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") > 0) // 细胞因子类制品费（P777）
                    && (medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") > 0) // 检查用一次性医用材料费（P778）
                    && (medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") > 0) // 治疗用一次性医用材料费（P779）
                    && (medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") > 0) // 手术用一次性医用材料费（P780）
                    && (medicalRecordQuality.getExpenseMap().get("qiTaf") != null && (medicalRecordQuality.getExpenseMap().get("qiTaf")) > 0) // 其他费（P781）
                    ) {
            	
                BigDecimal costAmount = new BigDecimal(medicalRecordQuality.getIpinfo().getP00800000().toString());
                BigDecimal sumFee =  new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf").toString())
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("huLif").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("bingLizdf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("shiYanShizdf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuzlf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("kangFuf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiYaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongChengYaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongCaoYaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("xuef").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiTaf").toString()));
                if (costAmount.compareTo(sumFee) != 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts04
     * RULE_NAME: 住院总费用-4
     * RULE_INTRODUCTION: 分项费用部分有值时，住院总费用应大于等于各分项费用（除自付金额,临床物理治疗费,麻醉费,手术费,抗菌药物费用外）之和。
     * P782≥P752+P754+P755+P756+P757+P758+P759+P760+P761+P763+P767+P768+P769+P771+P772+P773+P774+P775+P776+P777+P778+P779+P780+P781
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleIPCosts04(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() != null) {
            BigDecimal costAmount = new BigDecimal(medicalRecordQuality.getIpinfo().getP00800000().toString());
            BigDecimal sumFee = new BigDecimal("0");
 
            if (medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") != null && medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") > 0) { // 一般医疗服务费（P752）           
            	sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") != null && medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") > 0) { // 一般治疗操作费（P754）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("huLif") != null && medicalRecordQuality.getExpenseMap().get("huLif") > 0) { // 护理费（P755）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("huLif").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") != null && medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") > 0) { // 综合医疗服务类其他费用（P756）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("bingLizdf") != null && medicalRecordQuality.getExpenseMap().get("bingLizdf") > 0) { // 病理诊断费（P757）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("bingLizdf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("shiYanShizdf") != null && medicalRecordQuality.getExpenseMap().get("shiYanShizdf") > 0) { // 实验室诊断费（P758）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("shiYanShizdf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) { // 影像学诊断费（P759）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") > 0) { // 临床诊断项目费（P760）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") > 0) { // 非手术治疗项目费（P761）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) { // 手术治疗费（P763）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuzlf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("kangFuf") != null && medicalRecordQuality.getExpenseMap().get("kangFuf") > 0) { // 康复费（P767）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("kangFuf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") != null && medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") > 0) { // 中医治疗费（P768）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("xiYaof") > 0) { // 西药费（P769）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiYaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhongChengYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongChengYaof") > 0) { // 中成药费（P771）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongChengYaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") > 0) { // 中草药费（P772）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongCaoYaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("xuef") != null && medicalRecordQuality.getExpenseMap().get("xuef") > 0) { // 血费（P773）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("xuef").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") > 0) { // 白蛋白类制品费（P774）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") > 0) { // 球蛋白类制品费（P775）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") > 0) { // 凝血因子类制品费（P776）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") > 0) { // 细胞因子类制品费（P777）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") > 0) { // 检查用一次性医用材料费（P778）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") > 0) { // 治疗用一次性医用材料费（P779）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf").toString()));
            }                                             
            if (medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") > 0) { // 手术用一次性医用材料费（P780）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("qiTaf") != null && (medicalRecordQuality.getExpenseMap().get("qiTaf")) > 0) { // 其他费（P781）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiTaf").toString()));
            }
           
            if (costAmount.compareTo(sumFee) == -1) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Payment
     * RULE_NAME: 自付费用
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void rulePayment(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00810000() == null || medicalRecordQuality.getIpinfo().getP00810000() < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee01
     * RULE_NAME: 综合医疗服务类-一般医疗服务费(1)
     * RULE_INTRODUCTION: 综合医疗服务类-一般医疗服务费(1)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee01(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") != null && medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee02
     * RULE_NAME: 综合医疗服务类-一般治疗操作费(2)
     * RULE_INTRODUCTION: 综合医疗服务类-一般治疗操作费(2)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee02(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") != null && medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee03
     * RULE_NAME: 综合医疗服务类-护理费(3)
     * RULE_INTRODUCTION: 综合医疗服务类-护理费(3)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee03(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("huLif") != null && medicalRecordQuality.getExpenseMap().get("huLif") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee04
     * RULE_NAME: 综合医疗服务类-其他费用(4)
     * RULE_INTRODUCTION: 综合医疗服务类-其他费用(4)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee04(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") != null && medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee05
     * RULE_NAME: 诊断类-病理诊断费(5)
     * RULE_INTRODUCTION: 诊断类-病理诊断费(5)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee05(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("bingLizdf") != null && medicalRecordQuality.getExpenseMap().get("bingLizdf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee06
     * RULE_NAME: 诊断类-实验室诊断费(6)
     * RULE_INTRODUCTION: 诊断类-实验室诊断费(6)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee06(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shiYanShizdf") != null && medicalRecordQuality.getExpenseMap().get("shiYanShizdf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee07
     * RULE_NAME: 诊断类-影像学诊断费(7)
     * RULE_INTRODUCTION: 诊断类-影像学诊断费(7)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee07(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee08
     * RULE_NAME: 诊断类-临床诊断项目费(8)
     * RULE_INTRODUCTION: 诊断类-临床诊断项目费(8)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee08(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee09
     * RULE_NAME: 治疗类-非手术治疗项目费(9)
     * RULE_INTRODUCTION: 治疗类-非手术治疗项目费(9)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee09(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HF09ClinicPhysiotherapyFee
     * RULE_NAME: 治疗类-9-临床物理治疗费
     * RULE_INTRODUCTION: 治疗类-9-临床物理治疗费：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHF09ClinicPhysiotherapyFee(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") != null && medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee09II
     * RULE_NAME: 非手术治疗项目费
     * RULE_INTRODUCTION: 非手术治疗项目费必须大于等于临床物理治疗费
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleHospitalFee09II(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") != null) {
        	BigDecimal fzllffssf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf").toString());
        	BigDecimal fzllfwlzwlf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf").toString());
            if (fzllffssf.compareTo(fzllfwlzwlf) < 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        } else if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") == null && medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") != null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee10
     * RULE_NAME: 治疗类-手术治疗费(10)
     * RULE_INTRODUCTION: 治疗类-手术治疗费(10)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee10(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HF10AnesthesiaFee
     * RULE_NAME: 治疗类-10-麻醉费
     * RULE_INTRODUCTION: 治疗类-10-麻醉费：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHF10AnesthesiaFee(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HF10OperationFee
     * RULE_NAME: 治疗类-10-手术费
     * RULE_INTRODUCTION: 治疗类-10-手术费：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHF10OperationFee(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuf") != null && medicalRecordQuality.getExpenseMap().get("shouShuf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee10II
     * RULE_NAME: 手术治疗费
     * RULE_INTRODUCTION: 手术治疗费必须大于等于麻醉费与手术费之和
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleHospitalFee10II(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("shouShuf") != null) {
        	BigDecimal fzllfssf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuzlf").toString()); // 手术治疗费
            BigDecimal fzllfmzf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("maZuif").toString()); // 麻醉费
            BigDecimal fzllfsszlf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuf").toString()); // 手术费
            if (fzllfssf.compareTo(fzllfmzf.add(fzllfsszlf)) < 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        } else if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") == null && (medicalRecordQuality.getExpenseMap().get("maZuif") != null || medicalRecordQuality.getExpenseMap().get("shouShuf") != null)) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee11
     * RULE_NAME: 康复类-康复费(11)
     * RULE_INTRODUCTION: 康复类-康复费(11)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee11(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("kangFuf") != null && medicalRecordQuality.getExpenseMap().get("kangFuf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee12
     * RULE_NAME: 中医类-中医治疗费(12)
     * RULE_INTRODUCTION: 中医类-中医治疗费(12)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee12(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") != null && medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee13
     * RULE_NAME: 西药类-西药费(13)
     * RULE_INTRODUCTION: 西药类-西药费(13)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee13(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("xiYaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HF13AntibioticsFee
     * RULE_NAME: 西药类-13-抗菌药物费用
     * RULE_INTRODUCTION: 西药类-13-抗菌药物费用：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHF13AntibioticsFee(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") != null && medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee13II
     * RULE_NAME: 西药费
     * RULE_INTRODUCTION: 西药费必须大于等于抗菌药物费用
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleHospitalFee13II(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") != null) {
            Double fxyf = medicalRecordQuality.getExpenseMap().get("xiYaof");
            Double fxylgjf = medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy");
            if (fxyf.compareTo(fxylgjf) < 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        } else if (medicalRecordQuality.getExpenseMap().get("xiYaof") == null && medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") != null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee14
     * RULE_NAME: 中药类-中成药费(14)
     * RULE_INTRODUCTION: 中药类-中成药费(14)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee14(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhongChengYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongChengYaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee15
     * RULE_NAME: 中药类-中草药费(15)
     * RULE_INTRODUCTION: 中药类-中草药费(15)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee15(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee16
     * RULE_NAME: 血液和血液制品类-血费(16)
     * RULE_INTRODUCTION: 血液和血液制品类-血费(16)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee16(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xuef") != null && medicalRecordQuality.getExpenseMap().get("xuef") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee17
     * RULE_NAME: 血液和血液制品类-白蛋白类制品费(17)
     * RULE_INTRODUCTION: 血液和血液制品类-白蛋白类制品费(17)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee18
     * RULE_NAME: 血液和血液制品类-球蛋白类制品费(18)
     * RULE_INTRODUCTION: 血液和血液制品类-球蛋白类制品费(18)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee18(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee19
     * RULE_NAME: 血液和血液制品类-凝血因子类制品费(19)
     * RULE_INTRODUCTION: 血液和血液制品类-凝血因子类制品费(19)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee19(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee20
     * RULE_NAME: 血液和血液制品类-细胞因子类制品费(20)
     * RULE_INTRODUCTION: 血液和血液制品类-细胞因子类制品费(20)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee20(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee21
     * RULE_NAME: 耗材类-检查用一次性医用材料费(21)
     * RULE_INTRODUCTION: 耗材类-检查用一次性医用材料费(21)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee21(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee22
     * RULE_NAME: 耗材类-治疗用一次性医用材料费(22)
     * RULE_INTRODUCTION: 耗材类-治疗用一次性医用材料费(22)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee22(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee23
     * RULE_NAME: 耗材类-手术用一次性医用材料费(23)
     * RULE_INTRODUCTION: 耗材类-手术用一次性医用材料费(23)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee23(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee24
     * RULE_NAME: 其他类-其他费(24)
     * RULE_INTRODUCTION: 其他类-其他费(24)：费用不允许小于0
     *
     * @param medicalRecordQuality, rule
     * @Author: chenhanlin
     * @Date: 17/07/2017 11:49 AM
     */
    private void ruleHospitalFee24(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("qiTaf") != null && medicalRecordQuality.getExpenseMap().get("qiTaf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
/** ========================== 中铁十七局的 校验规则  start ========================== */
    /**
     * Annotation:
     * RULE_CODE: RULE-BirthWeight_ZhongTie17
     * RULE_NAME: 新生儿出生体重（可能多胎）
     * RULE_INTRODUCTION: 一定条件下必填，当其它诊断编码为Z37，或（年龄不足1周岁的）年龄≤28天，或入院日期减出生日期≤28天时，新生儿出生体重不能为空
     *,填写数值精确到10g，否则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleBirthWeight_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        
    	// 1. 当其他诊断编码为Z37时，新生儿出生体重为必填项,填写数值精确到10g
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if (!StringUtils.isBlank(diagnose.getPd0101())) {
                if (diagnose.getPd0101().matches("Z37.*") && "O".equals(diagnose.getPdType())) {
                    if (medicalRecordQuality.getBaseInfo().getP00110000() == null || medicalRecordQuality.getBaseInfo().getP00110000()<= 0 || medicalRecordQuality.getBaseInfo().getP00110000() % 10 != 0) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }

        // 2. （年龄不足1周岁的）年龄≤28天，新生儿出生体重为必填项,填写数值精确到10g
        // 年龄(天)有值 && 年龄(年)和年龄(月)没有值或是0
        if (medicalRecordQuality.getBaseInfo().getP00090002() != null && (medicalRecordQuality.getBaseInfo().getP00090000() == null || medicalRecordQuality.getBaseInfo().getP00090000() == 0)
                && (medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001() == 0)) {
            int ageDays = medicalRecordQuality.getBaseInfo().getP00090002();
            if (ageDays > 0 && ageDays <= 28) {
                if (medicalRecordQuality.getBaseInfo().getP00110000() == null || medicalRecordQuality.getBaseInfo().getP00110000()<= 0 || medicalRecordQuality.getBaseInfo().getP00110000() % 10 != 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }

        // 3. 入院日期减出生日期≤28天时，新生儿出生体重为必填项,填写数值精确到10g
        Date birthday, inDate;
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) { // 出生日期为空则不校验
            return;
        } else {
            birthday = medicalRecordQuality.getBaseInfo().getP00080000();
        }
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) { // 入院日期不校验
            return;
        } else {
            inDate = medicalRecordQuality.getIpinfo().getP00250000();
        }

        int days = differentDays(birthday,inDate) ;
        if (days <= 28 && days > 0) {
            if (medicalRecordQuality.getBaseInfo().getP00110000() == null || medicalRecordQuality.getBaseInfo().getP00110000()<= 0 || medicalRecordQuality.getBaseInfo().getP00110000() % 10 != 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
        //否则划-
        
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPWeight_ZhongTie17
     * RULE_NAME: 新生儿入院体重
     * RULE_INTRODUCTION: 一定条件下必填，（年龄不足1周岁的）年龄≤28天，或入院日期减出生日期≤28天时，新生儿入院体重不能为空
     *,填写数值精确到10g，否则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleIPWeight_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 1. （年龄不足1周岁的）年龄≤28天，新生儿入院体重为必填项
        // 年龄(天)有值 && 年龄(年)和年龄(月)没有值或是0
        if (medicalRecordQuality.getBaseInfo().getP00090002() != null && (medicalRecordQuality.getBaseInfo().getP00090000() == null || medicalRecordQuality.getBaseInfo().getP00090000() == 0)
                && (medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001() == 0)) {
            int ageDays = medicalRecordQuality.getBaseInfo().getP00090002();
            if (ageDays > 0 && ageDays <= 28) {
                if (medicalRecordQuality.getBaseInfo().getP00120000() == null || medicalRecordQuality.getBaseInfo().getP00120000()<= 0 || medicalRecordQuality.getBaseInfo().getP00120000() % 10 != 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }

        // 2. 入院日期减出生日期≤28天时，新生儿入院体重为必填项
        Date birthday, inDate;
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) {
            return;
        } else {
            birthday = medicalRecordQuality.getBaseInfo().getP00080000();
        }
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) {
            return;
        } else {
            inDate = medicalRecordQuality.getIpinfo().getP00250000();
        }

        int days = differentDays(inDate,birthday) ;
        if (days <= 28 && days > 0) {
            if (medicalRecordQuality.getBaseInfo().getP00120000() == null || medicalRecordQuality.getBaseInfo().getP00120000()<= 0 || medicalRecordQuality.getBaseInfo().getP00120000() % 10 != 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    
    /**
     * Annotation:
     * RULE_CODE: RULE-CaseNo_ZhongTie17
     * RULE_NAME: 病案号
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleCaseNo_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00050000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    
    /**
     * Annotation:
     * RULE_CODE: RULE-Age01_ZhongTie17
     * RULE_NAME: 年龄-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAge01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if ((medicalRecordQuality.getBaseInfo().getP00090000() == null || medicalRecordQuality.getBaseInfo().getP00090000()<= 0)
                && (medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001()<= 0)
                && (medicalRecordQuality.getBaseInfo().getP00090002() == null || medicalRecordQuality.getBaseInfo().getP00090002()<= 0)) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Age02_ZhongTie17
     * RULE_NAME: 年龄-2
     * RULE_INTRODUCTION: 年龄等于入院日期减出生日期（误差范围1岁）
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAge02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        Date birthday, inDate;
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) {
            return;
        } else {
            birthday = medicalRecordQuality.getBaseInfo().getP00080000();
        }
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) {
            return;
        } else {
            inDate = medicalRecordQuality.getIpinfo().getP00250000();
        }


        // 计算年龄 = 入院日期-出生日期
        int age = getAge(birthday,inDate);
        if (medicalRecordQuality.getBaseInfo().getP00090000() != null && medicalRecordQuality.getBaseInfo().getP00090000() > 0) {
            int ageYear = medicalRecordQuality.getBaseInfo().getP00090000();
            if (Math.abs(ageYear - age) > 1) {
                saveViolationInfo(medicalRecordQuality, rule);
                return;
            }
        }
        
        //年龄（月）
        int days=differentDays(birthday,inDate);
        if (medicalRecordQuality.getBaseInfo().getP00090001() != null && medicalRecordQuality.getBaseInfo().getP00090001() > 0) {
            long ageMonth = medicalRecordQuality.getBaseInfo().getP00090001().longValue();
            if (Math.abs(ageMonth * 30 - days) > 365) {
                saveViolationInfo(medicalRecordQuality, rule);
                return;
            }
        }
        //年龄（天）
        if (medicalRecordQuality.getBaseInfo().getP00090002() != null && medicalRecordQuality.getBaseInfo().getP00090002() > 0) {
            long ageDays = medicalRecordQuality.getBaseInfo().getP00090002().longValue();
            if (Math.abs(ageDays - days) > 365) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AgeMonth01_ZhongTie17
     * RULE_NAME: 不足一周岁年龄（月天）-1
     * RULE_INTRODUCTION: 当门（急）诊诊断编码、主要诊断编码、其它诊断编码出现P10～P15时，入院日期减出生日期必须≤28天，且（年龄不足1周岁的）年龄必须≤28天，
     *
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAgeMonth01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            String diagCode = diagnose.getPd0101();
            if (!StringUtils.isBlank(diagCode) && diagCode.matches("P1[0-5].*")) {
                // 不足一周岁
                if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getBaseInfo().getP00080000() != null) {
                    if ((medicalRecordQuality.getBaseInfo().getP00090002() == null || medicalRecordQuality.getBaseInfo().getP00090002()<= 0)
                            || (medicalRecordQuality.getBaseInfo().getP00090000() != null && medicalRecordQuality.getBaseInfo().getP00090000() != 0)
                            || (medicalRecordQuality.getBaseInfo().getP00090001() != null && medicalRecordQuality.getBaseInfo().getP00090001() != 0)) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    } else {
                        long days = (medicalRecordQuality.getIpinfo().getP00250000().getTime() - medicalRecordQuality.getBaseInfo().getP00080000().getTime()) / 1000 / 60 / 60 / 24;
                        int ageDays = medicalRecordQuality.getBaseInfo().getP00090002().intValue();
                        if (!(days <= 28 && days > 0 && ageDays <= 28 && ageDays > 0)) {
                            saveViolationInfo(medicalRecordQuality, rule);
                            return;
                        }
                    }
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AgeMonth02_ZhongTie17
     * RULE_NAME: 不足一周岁年龄（月天）-2
     * RULE_INTRODUCTION: 年龄小于1周岁即年龄为0时，（年龄不足1周岁的）年龄不能为空
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAgeMonth02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getBaseInfo().getP00090000() != null && medicalRecordQuality.getBaseInfo().getP00090000() == 0) {
            if ((medicalRecordQuality.getBaseInfo().getP00090001() == null || medicalRecordQuality.getBaseInfo().getP00090001() == 0)
                    && (medicalRecordQuality.getBaseInfo().getP00090002() == null || medicalRecordQuality.getBaseInfo().getP00090002() == 0)) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Birthday01_ZhongTie17
     * RULE_NAME: 出生日期
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleBirthday01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Birthday02_ZhongTie17
     * RULE_NAME: 出生日期
     * RULE_INTRODUCTION: 必须与身份证号码相符
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleBirthday02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getBaseInfo().getP00080000() == null) {       	
            saveViolationInfo(medicalRecordQuality, rule);
        }else if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00160000())){
        	//身份证号不能为空
        	saveViolationInfo(medicalRecordQuality, rule);
        }else if( medicalRecordQuality.getBaseInfo().getP00160000().length()>14){
        	String IDBirthday = medicalRecordQuality.getBaseInfo().getP00160000().substring(6,14);
        	SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        	if(!IDBirthday.equals(formatter.format(medicalRecordQuality.getBaseInfo().getP00080000()))){
        		saveViolationInfo(medicalRecordQuality, rule);
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Gender01_ZhongTie17
     * RULE_NAME: 性别-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleGender01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00070001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Gender02_ZhongTie17
     * RULE_NAME: 性别-2
     * RULE_INTRODUCTION: 当性别为男性时，门（急）诊诊断编码、主要诊断编码、其它诊断编码不能使用以下编码：
     * A34；B37.3；C51-C58；C79.6；D06；D07.0-D07.3；D25-D28；D39；E28；E89.4；F52.5；F53；I86.3；L29.2；M80.0-M80.1；
     * M81.0-M81.1；M83.0；N70-N98；N99.2-N99.3；O00-O99；P54.6；Q50-Q52；R87；S31.4；S37.4-S37.6；T19.2-T19.3；T83.3；
     * Z01.4；Z12.4；Z30.1；Z30.3；Z30.5；Z31.1-Z31.2；Z32-Z37；Z39；Z87.5；Z97.5
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleGender02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        String sexCode = medicalRecordQuality.getBaseInfo().getP00070001();
        String sexDesc = dictionaryMap.get("gender").get(sexCode) ;
        if (!StringUtils.isBlank(sexCode)) {
            if (sexDesc !=null && sexDesc.contains("男")) {
                String[] codes = {
                        "A34", "B37.3", "C51", "C52", "C53", "C54", "C55", "C56", "C57", "C58", // 10
                        "C79.6", "D06", "D07.0", "D07.1", "D07.2", "D07.3", "D25", "D26", "D27", "D28", // 10
                        "D39", "E28", "E89.4", "F52.5", "F53", "I86.3", "L29.2", "M80.0", "M80.1", "M81.0", // 10
                        "M81.1", "M83.0", "N99.2", "N99.3", "P54.6", "Q50", "Q51", "Q52", "R87", "S31.4", // 10
                        "S37.4", "S37.5", "S37.6", "T19.2", "T19.3", "T83.3", "Z01.4", "Z12.4", "Z30.1", "Z30.3", // 10
                        "Z30.5", "Z31.1", "Z31.2", "Z32", "Z33", "Z34", "Z35", "Z36", "Z37", "Z39", // 10
                        "Z87.5", "Z97.5"};
                List<String> codeList = new ArrayList<>(); // 编码集合
                Collections.addAll(codeList, codes);
                // O00-O99
                for (int i = 0; i < 100; i++) {
                    codeList.add("O" + (i / 10 > 0 ? i : "0" + i));
                }
                // N70-N98
                for (int i = 70; i < 99; i++) {
                    codeList.add("N" + i);
                }
                
                List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
                for (MrDiagnose diagnose : diagnoseList) {
                    if (!StringUtils.isBlank(diagnose.getPd0101())) {
                        for (String code : codeList) {
                            if (diagnose.getPd0101().matches(code + ".*")) {
                                saveViolationInfo(medicalRecordQuality, rule);
                                return;
                            }
                        }
                    }
                }
                
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Gender03_ZhongTie17
     * RULE_NAME: 性别-3
     * RULE_INTRODUCTION: 当性别为女性时，门（急）诊诊断编码、主要诊断编码、其它诊断编码不能使用以下编码：
     * B26.0；C60-C63；D07.4-D07.6；D17.6；D29；D40；E29；E89.5；F52.4；I86.1；L29.1；N40-N51；Q53-Q55；R86；S31.2-S31.3；Z12.5
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleGender03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        String sexCode = medicalRecordQuality.getBaseInfo().getP00070001();
        String sexDesc = dictionaryMap.get("gender").get(sexCode) ;
        if (!StringUtils.isBlank(sexCode)) {
            if (sexDesc !=null && sexDesc.contains("女")) {
                String[] codes = {
                        "B26.0", "C60", "C61", "C62", "C63", "D07.4", "D07.5", "D07.6", "D17.6", "D29", // 10
                        "D40", "E29", "E89.5", "F52.4", "I86.1", "L29.1", "Q53", "Q54", "Q55", "R86", // 10
                        "S31.2", "S31.3", "Z12.5"}; // 3
                List<String> codeList = new ArrayList<>(); // 编码集合
                Collections.addAll(codeList, codes);
                // N40-N51
                for (int i = 40; i < 52; i++) {
                    codeList.add("N" + i);
                }

                List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
                for (MrDiagnose diagnose : diagnoseList) {
                    if (!StringUtils.isBlank(diagnose.getPd0101())) {
                        for (String code : codeList) {
                            if (diagnose.getPd0101().matches(code + ".*")) {
                                saveViolationInfo(medicalRecordQuality, rule);
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PaymentMode_ZhongTie17
     * RULE_NAME: 医疗付费方式
     * RULE_INTRODUCTION: 必填项
     * <p>
     * 01	城镇职工基本医疗保险
     * 02	城镇居民基本医疗保险
     * 03	新型农村合作医疗
     * 04	贫困救助
     * 05	商业医疗保险
     * 06	全公费
     * 07	全自费
     * 08	其他社会保险
     * 99	其他
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void rulePaymentMode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        String payment = medicalRecordQuality.getBaseInfo().getP00020001();
        Map<String,String> paymentMap = dictionaryMap.get("paymentMode") ;
        // 是否为空
        if(StringUtils.isBlank(payment)){
            saveViolationInfo(medicalRecordQuality, rule);
            return ;
        }
        // 是否在字典里
        if (!paymentMap.containsKey(payment)) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Address_ZhongTie17
     * RULE_NAME: 现住址（省、市、县、街道）
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAddress_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190100()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190200())
                && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190300()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190400())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /** 
     * Annotation:
     * RULE_CODE: RULE-Birthplace_ZhongTie17
     * RULE_NAME: 出生地（省、市、县）
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleBirthplace_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130100()) && 
        		StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130200())&& StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00130300())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Career_ZhongTie17
     * RULE_NAME: 职业
     * RULE_INTRODUCTION: 必填项，年龄小于14岁时，职业不允许为11.国家公务员 37.现役军人 80.退离休人员
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleCareer_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00170000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }else if(medicalRecordQuality.getBaseInfo().getP00090000().intValue() <14){
        	if (medicalRecordQuality.getBaseInfo().getP00170000().matches("11|37|80")) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ContactName_ZhongTie17
     * RULE_NAME: 联系人姓名
     * RULE_INTRODUCTION: 必填项 
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleContactName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Relationship_ZhongTie17
     * RULE_NAME: 联系人关系
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleRelationship_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220100())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ContactAddress_ZhongTie17
     * RULE_NAME: 联系人地址
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleContactAddress_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ContactTelephone_ZhongTie17
     * RULE_NAME: 联系人电话 
     * RULE_INTRODUCTION: 必填项 长度为11位或7位
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleContactTelephone_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00220300())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }else if (medicalRecordQuality.getBaseInfo().getP00220300().length() != 7 && medicalRecordQuality.getBaseInfo().getP00220300().length() != 11) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    
    /**
     * Annotation:
     * RULE_CODE: RULE-HealthCardNo_ZhongTie17
     * RULE_NAME: 健康卡号
     * RULE_INTRODUCTION: 有：填写健康卡号或就医卡号，无：划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleHealthCardNo_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00030000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IDNo_ZhongTie17
     * RULE_NAME: 身份证号
     * RULE_INTRODUCTION: 必填项.如实填写18位身份证号码，与出生日期、年龄相对应
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleIDNo_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00160000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }else if(medicalRecordQuality.getBaseInfo().getP00160000().length() != 18){
        	saveViolationInfo(medicalRecordQuality, rule);
        }else{
        	String IDBirthday = medicalRecordQuality.getBaseInfo().getP00160000().substring(6,14);
        	SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        	if(!IDBirthday.equals(formatter.format(medicalRecordQuality.getBaseInfo().getP00080000()))){
        		saveViolationInfo(medicalRecordQuality, rule);
        	}else{
        		if(medicalRecordQuality.getIpinfo().getP00250000() != null ){
	        		try {
						Date birthday = formatter.parse(IDBirthday);
						Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
						int age = getAge(birthday,inDate);
						if(age != medicalRecordQuality.getBaseInfo().getP00090000() ){
							saveViolationInfo(medicalRecordQuality, rule);
						}
					} catch (ParseException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
        		}
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IPTimes_ZhongTie17
     * RULE_NAME: 第XXX次住院
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleIPTimes_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getBaseInfo().getP00040000() == null || medicalRecordQuality.getBaseInfo().getP00040000()<= 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /** 
     * Annotation:
     * RULE_CODE: RULE-Marriage01_ZhongTie17
     * RULE_NAME: 婚姻
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleMarriage01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00180000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /** 
     * Annotation:
     * RULE_CODE: RULE-Marriage02_ZhongTie17
     * RULE_NAME: 婚姻
     * RULE_INTRODUCTION: 患者年龄小于14岁时，只能填1，婚姻状况为“丧偶”时，联系人关系不可填写丈夫或妻子
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleMarriage02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (null != medicalRecordQuality.getBaseInfo().getP00090000() && medicalRecordQuality.getBaseInfo().getP00090000().intValue() <14) {
        	if(!"1".equals( medicalRecordQuality.getBaseInfo().getP00180000() )){
        		saveViolationInfo(medicalRecordQuality, rule);
        	}
        }else if (null != medicalRecordQuality.getBaseInfo().getP00090000() && "3".equals( medicalRecordQuality.getBaseInfo().getP00180000() ) ) {
        	//1 未婚，2 已婚， 3 丧偶， 4 离婚
        	if("1".equals( medicalRecordQuality.getBaseInfo().getP00220100() )){
        		//0 本人或户主， 1 配偶， 2 子， 3 女
        		saveViolationInfo(medicalRecordQuality, rule);
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Name_ZhongTie17
     * RULE_NAME: 姓名
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00060000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Nationality_ZhongTie17
     * RULE_NAME: 国籍
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleNationality_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00100000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Nation_ZhongTie17
     * RULE_NAME: 民族
     * RULE_INTRODUCTION: 必填项 国籍为中国时，民族不允许为99.其他
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleNation_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {        
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00150000())) {
            // 没有或不在字典之中
            saveViolationInfo(medicalRecordQuality, rule);
        }else{
        	String nation =  medicalRecordQuality.getBaseInfo().getP00100000() ;
        	String nationDesc = dictionaryMap.get("nationality").get(nation) ;
            if (!StringUtils.isBlank(nationDesc)) {
                if ( nationDesc.contains("中国") ) {
                	if("99".equals(medicalRecordQuality.getBaseInfo().getP00150000()) ){
                		saveViolationInfo(medicalRecordQuality, rule);
                	}
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-NativePlace01_ZhongTie17
     * RULE_NAME: 籍贯
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleNativePlace01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140100()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-NativePlace02_ZhongTie17
     * RULE_NAME: 籍贯
     * RULE_INTRODUCTION: 具体到省市
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleNativePlace02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140100()) || StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00140200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-RegisteredAddress_ZhongTie17
     * RULE_NAME: 户口地址（省、市、县、街道）
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleRegisteredAddress_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200100()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200200())
                && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200300()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200400())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-RegisteredZIPCode_ZhongTie17
     * RULE_NAME: 户口地址邮编
     * RULE_INTRODUCTION: 必填项  长度为6位
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleRegisteredZIPCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00200500())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }else if(medicalRecordQuality.getBaseInfo().getP00200500().length() !=6){
        	saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AddressDetail_ZhongTie17
     * RULE_NAME: 现住址地址
     * RULE_INTRODUCTION: 具体到（省、市、县、街道）必填
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAddressDetail_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190100()) || StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190200())
        		|| StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190300()) || StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190400())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AddressDetail01_ZhongTie17
     * RULE_NAME: 现住址地址
     * RULE_INTRODUCTION: （省、市、县、街道、详细地址选填）
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAddressDetail01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190000()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190100()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190200())
        		&& StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190300()) && StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190400())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Telephone_ZhongTie17
     * RULE_NAME: 现住址电话
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleTelephone_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190500())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ZIPCode_ZhongTie17
     * RULE_NAME: 现住址邮编
     * RULE_INTRODUCTION: 必填项  长度为6位
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleZIPCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00190600())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }else if(medicalRecordQuality.getBaseInfo().getP00190600().length() !=6 ){
        	saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-UnitAddress_ZhongTie17
     * RULE_NAME: 工作单位及地址
     * RULE_INTRODUCTION: 必填项，
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleUnitAddress_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00210000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-UnitTelephone_ZhongTie17
     * RULE_NAME: 工作单位电话
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleUnitTelephone_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00210100())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-UnitZIPCode_ZhongTie17
     * RULE_NAME: 工作单位邮编
     * RULE_INTRODUCTION: 必填项 长度为6位
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleUnitZIPCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00210200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }else if(medicalRecordQuality.getBaseInfo().getP00210200().length() !=6 ){
        	saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OrgName_ZhongTie17
     * RULE_NAME: 医疗机构
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    public void ruleOrgName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
//        String orgCode = medicalRecordQuality.getBaseInfo().getP00010000();
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00010000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-OrgCode_ZhongTie17
     * RULE_NAME: 组织机构代码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    public void ruleOrgCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getBaseInfo().getP00010001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeMode01_ZhongTie17
     * RULE_NAME: 离院方式-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeMode01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeMode02_ZhongTie17
     * RULE_NAME: 离院方式-2
     * RULE_INTRODUCTION: 有“尸体料理费”的患者，“离院方式”都只能为“死亡” 离院方式选择2或3的，拟接收医疗机构名称必须填，其它选项要在其后划-；选择4时，主要诊断出院时情况不能为治愈
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeMode02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // T_MEDICALRECORD 中无“尸体料理费”字段 标准病案无此项
    	//离院方式选择2或3的，拟接收医疗机构名称必须填，其它选项要在其后划-
        if ("2".equals(medicalRecordQuality.getIpinfo().getP00620001()) ) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620100())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
        if ("3".equals(medicalRecordQuality.getIpinfo().getP00620001()) ) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620200())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
        //选择4时，主要诊断出院时情况不能为治愈  1.治愈2.好转3.未愈4.死亡5.其他
        if ("4".equals(medicalRecordQuality.getIpinfo().getP00620001()) ) {
            List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
            for (MrDiagnose diagnose : diagnoseList) {
                if ("M".equals(diagnose.getPdType())) {//主要诊断
                    if ("1".equals(diagnose.getPd0301())) {//主要诊断出院时情况不能为治愈  1.治愈2.好转3.未愈4.死亡5.其他
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDate01_ZhongTie17
     * RULE_NAME: 入院时间-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionDate01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() == null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDate02_ZhongTie17
     * RULE_NAME: 入院时间-2
     * RULE_INTRODUCTION: 入院日期≤出院日期
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionDate02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            // 如果入院日期大于出院日期
            if (inDate!=null && outDate!= null && inDate.compareTo(outDate) > 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDate03_ZhongTie17
     * RULE_NAME: 入院时间-3
     * RULE_INTRODUCTION: 入院日期≤手术操作日期
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionDate03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                Date operDate = mrOperation.getPo0200();
              //因为手术操作日期精确到日2019-01-01，入院日期精确到分2019-01-01 15:16:00，所以不能用compareTo进行比较
                if (inDate != null && operDate!= null && differentDays(operDate,inDate) > 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    break;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDate01_ZhongTie17
     * RULE_NAME: 出院时间-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeDate01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00290000() == null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDate02_ZhongTie17
     * RULE_NAME: 出院时间-2
     * RULE_INTRODUCTION: 入院日期≤出院日期
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeDate02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            if (inDate!=null && outDate!=null && inDate.compareTo(outDate) > 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDate03_ZhongTie17
     * RULE_NAME: 出院时间-3
     * RULE_INTRODUCTION: 入院日期≤手术操作日期≤出院日期
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeDate03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) { // 获取一个病案的最早的手术日期
                Date operDate = mrOperation.getPo0200();
                //因为手术操作日期精确到日2019-01-01，入院日期精确到分2019-01-01 15:16:00，所以不能用compareTo进行比较
                if (operDate != null && inDate!=null && outDate!=null && !(differentDays(inDate,operDate) >= 0 && differentDays(operDate,outDate) >= 0)) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    break;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDepCode_ZhongTie17
     * RULE_NAME: 出院科别编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeDepCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00300001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeDepDesc_ZhongTie17
     * RULE_NAME: 出院科别描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeDepDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00300000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IsInner31Days_ZhongTie17
     * RULE_NAME: 是否有31天内再次入院计划
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleIsInner31Days_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00630001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    
    /**
     * Annotation:
     * RULE_CODE: RULE-Inner31DaysPurpose_ZhongTie17
     * RULE_NAME: 31天内再次入院目的
     * RULE_INTRODUCTION: 一定条件下必填，有31天内再入院计划的患者，再次住院目的，必填。
     * PS: 1-无   2-有
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleInner31DaysPurpose_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if ("2".equals(medicalRecordQuality.getIpinfo().getP00630001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00630100())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InpatientDays_ZhongTie17
     * RULE_NAME: 实际住院天数
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleInpatientDays_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00320000() == null || medicalRecordQuality.getIpinfo().getP00320000()<= 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDepCode_ZhongTie17
     * RULE_NAME: 入院科别编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionDepCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00260001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionDepDesc_ZhongTie17
     * RULE_NAME: 入院科别描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionDepDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00260000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionModeCode_ZhongTie17
     * RULE_NAME: 入院途径编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionModeCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00230001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionModeDesc_ZhongTie17
     * RULE_NAME: 入院途径描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionModeDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00230000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-TransferDep_ZhongTie17
     * RULE_NAME: 转科科别
     * RULE_INTRODUCTION: 入院科别 <> 出院科别 的情况下才填入转科科别
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleTransferDep_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!isBlankCode(medicalRecordQuality.getIpinfo().getP00260001()) && !isBlankCode(medicalRecordQuality.getIpinfo().getP00300001()) &&
                !medicalRecordQuality.getIpinfo().getP00260001().equals(medicalRecordQuality.getIpinfo().getP00300001()))
            // 转科科别
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00280001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ICUInDate01_ZhongTie17
     * RULE_NAME: （重症监护室）进入时间-1  P00930001
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleICUInDate01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00930000())) {
            if(medicalRecordQuality.getIpinfo().getP00930001() == null ){
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUInDate02_ZhongTie17
     * RULE_NAME: （重症监护室）进入时间-2
     * RULE_INTRODUCTION: 入院日期≤监护室进入时间≤监护室退出时间≤出院日期
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleICUInDate02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            Date inIcuDate = medicalRecordQuality.getIpinfo().getP00930001();
            Date outIcuDate = medicalRecordQuality.getIpinfo().getP00930002() ;
          //因为监护室进入时间、监护室退出时间都是精确到日2019-01-01，入院日期精确到分2019-01-01 15:16:00，所以不能用compareTo进行比较
            if (inIcuDate != null && inDate!=null && outDate!=null && outIcuDate!=null
            		&& !(differentDays(inDate,inIcuDate) >= 0 && differentDays(inIcuDate,outIcuDate) >= 0 && differentDays(outIcuDate,outDate)>=0)) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUOutDate01_ZhongTie17
     * RULE_NAME: （重症监护室）转出时间-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleICUOutDate01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00930000())) {
            if(medicalRecordQuality.getIpinfo().getP00930002() == null ){
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-ICUOutDate02_ZhongTie17
     * RULE_NAME: （重症监护室）转出时间-2
     * RULE_INTRODUCTION: 入院日期≤监护室进入时间≤监护室退出时间≤出院日期
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleICUOutDate02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00250000() != null && medicalRecordQuality.getIpinfo().getP00290000() != null) {
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
            Date inIcuDate = medicalRecordQuality.getIpinfo().getP00930001();
            Date outIcuDate = medicalRecordQuality.getIpinfo().getP00930002();
          //因为监护室进入时间、监护室退出时间都是精确到日2019-01-01，入院日期精确到分2019-01-01 15:16:00，所以不能用compareTo进行比较
            if (inIcuDate != null && inDate!=null && outDate!=null && outIcuDate!=null
            		&& !(differentDays(inDate,inIcuDate) >= 0 && differentDays(inIcuDate,outIcuDate) >= 0 && differentDays(outIcuDate,outDate)>=0)) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalTransferReceptionUnit_ZhongTie17
     * RULE_NAME: 医嘱转院接收单位
     * RULE_INTRODUCTION: 一定条件下必填，医嘱转院，该项必填
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleHospitalTransferReceptionUnit_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620001()) && "2".equals(medicalRecordQuality.getIpinfo().getP00620001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620100())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-CommunityTransferReceptionUnit_ZhongTie17
     * RULE_NAME: 医嘱转社区等医疗机构接收单位
     * RULE_INTRODUCTION: 一定条件下必填，医嘱转社区卫生服务机构/乡镇卫生院，该项必填
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleCommunityTransferReceptionUnit_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620001()) && "3".equals(medicalRecordQuality.getIpinfo().getP00620001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00620200())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionWardCode_ZhongTie17
     * RULE_NAME: （入院）病房编码
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionWardCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00270001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionWardDesc_ZhongTie17
     * RULE_NAME: （入院）病房编描述
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionWardDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00270000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DischargeWardCode_ZhongTie17
     * RULE_NAME: （出院）病房编码
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeWardCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00310001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

      /**
     * Annotation:
     * RULE_CODE: RULE-DischargeWardDesc_ZhongTie17
     * RULE_NAME: （出院）病房描述
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对病房未要求编码字典，故此处只校验病房文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDischargeWardDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankDesc(medicalRecordQuality.getIpinfo().getP00310000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnosisDescribe01_ZhongTie17
     * RULE_NAME: （主要出院诊断）名称
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDiagnosisDescribe01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
            for (MrDiagnose diagnose : diagnoseList) {
                // 判断是否是主诊断
                if("M".equals(diagnose.getPdType())){
                    if (StringUtils.isBlank(diagnose.getPd0100()) ) {
                        saveViolationInfo(medicalRecordQuality, rule);
                    }
                }
            }
    	}else if(medicalRecordQuality.getDiagnose().isEmpty()){
    		saveViolationInfo(medicalRecordQuality, rule);
    	} 
    	
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnosisDescribe02_ZhongTie17
     * RULE_NAME: （主要出院诊断）名称
     * RULE_INTRODUCTION: 只能填写一个诊断
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDiagnosisDescribe02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
    		int count = 0;
            for (MrDiagnose diagnose : diagnoseList) {
                // 判断是否是主诊断
                if("M".equals(diagnose.getPdType())){
                    if (!StringUtils.isBlank(diagnose.getPd0100()) ) {
                        count++;
                    }
                }
            }
            if(count != 1){
            	saveViolationInfo(medicalRecordQuality, rule);
            }
    	}
    	
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnosisCode01_ZhongTie17
     * RULE_NAME: （主要出院诊断）编码-1
     * RULE_INTRODUCTION: （主要出院诊断）编码的编码范围应为：A～U开头和Z开头的编码；不包括字母V、W、X、Y开头的编码
     * R65、B95-B97、T31、Z37-Z38、Z85-Z99不能做主要诊断编码
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDiagnosisCode01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
            for (MrDiagnose diagnose : diagnoseList) {
                // 判断是否是主诊断
                if("M".equals(diagnose.getPdType())){
                	String diagnosisCode = diagnose.getPd0101();
                    if(StringUtils.hasLength(diagnosisCode)){
                        if (!(diagnosisCode.substring(0, 1).matches("[A-U]") || "Z".equals(diagnosisCode.substring(0, 1)))
                        		||"R65,B95,B96,B97,T31,Z37,Z38,Z85,Z86,Z87,Z88,Z89,Z90,Z91,Z92,Z93,Z94,Z95,Z96,Z97,Z98,Z99".indexOf(diagnosisCode)>-1) {
                            saveViolationInfo(medicalRecordQuality, rule);
                        }
                    }
                }
            }
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnosisCode02_ZhongTie17
     * RULE_NAME: （主要出院诊断）编码-2
     * RULE_INTRODUCTION: 死亡患者主要诊断不允许为Z51、Z4的诊断编码
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleDiagnosisCode02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
    		//离院方式为 5 死亡
    		if("5".equals(medicalRecordQuality.getIpinfo().getP00620001())){
                for (MrDiagnose diagnose : diagnoseList) {
                    // 判断是否是主诊断
                    if("M".equals(diagnose.getPdType())){
                    	String diagnosisCode = diagnose.getPd0101();
                        if(StringUtils.hasLength(diagnosisCode)){
                            if ( "Z51,Z4".indexOf(diagnosisCode)>-1 ) {
                                saveViolationInfo(medicalRecordQuality, rule);
                            }
                        }
                    }
                }
    		}
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OutDiagnosisCode01_ZhongTie17
     * RULE_NAME: 出院诊断编码-1
     * RULE_INTRODUCTION: 病案首页12岁及以下儿童出院诊断不允许为C50-C63
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOutDiagnosisCode01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
    		//病案首页12岁及以下儿童出院诊断不允许为C50-C63
    		if( 12 >=  medicalRecordQuality.getBaseInfo().getP00090000().intValue() ){
                for (MrDiagnose diagnose : diagnoseList) {
                	String diagnosisCode = diagnose.getPd0101();
                    if(StringUtils.hasLength(diagnosisCode)){
                        if ( "Z51,Z4".indexOf(diagnosisCode)>-1 ) {
                            saveViolationInfo(medicalRecordQuality, rule);
                        }
                    }
                }
    		}
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnosisCode_ZhongTie17
     * RULE_NAME: 出院诊断编码-2
     * RULE_INTRODUCTION: 年龄大于28天，出院诊断编码中不允许为P00-P96的诊断编码
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOutDiagnosisCode02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
            Date birthday = medicalRecordQuality.getBaseInfo().getP00080000();            
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            int days=differentDays(birthday,inDate);
    		//年龄大于28天，出院诊断编码中不允许为P00-P96的诊断编码
    		if( days > 28 ){
                for (MrDiagnose diagnose : diagnoseList) {
                	String diagnosisCode = diagnose.getPd0101();
                    if(StringUtils.hasLength(diagnosisCode)){
                    	if ( diagnosisCode.matches("P[0-9]{2}.*") && !diagnosisCode.matches("P9[7-9].*") ) {
                            saveViolationInfo(medicalRecordQuality, rule);
                        }
                    }
                }
    		}
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnosisCode_ZhongTie17
     * RULE_NAME: 出院诊断编码-3
     * RULE_INTRODUCTION: 年龄小于28天新生儿，出院诊断编码应为P开头
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOutDiagnosisCode03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	if(diagnoseList.size()>0){
            Date birthday = medicalRecordQuality.getBaseInfo().getP00080000();            
            Date inDate = medicalRecordQuality.getIpinfo().getP00250000();
            int days=differentDays(birthday,inDate);
    		//年龄小于28天新生儿，出院诊断编码应为P开头
    		if( days < 28 || (null != medicalRecordQuality.getBaseInfo().getP00090002() && medicalRecordQuality.getBaseInfo().getP00090002().intValue() < 28 ) ){
                for (MrDiagnose diagnose : diagnoseList) {
                	String diagnosisCode = diagnose.getPd0101();
                    if(StringUtils.hasLength(diagnosisCode)){
                    	if ( !diagnosisCode.substring(0, 1).matches("[Pp]") ) {
                            saveViolationInfo(medicalRecordQuality, rule);
                            return;
                        }
                    }
                }
    		}
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurgeryName_ZhongTie17
     * RULE_NAME: （主要手术）名称
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
      * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleSurgeryName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0100())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationName_ZhongTie17
     * RULE_NAME: （主要操作）名称
     * RULE_INTRODUCTION: 有影像学诊断费的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOperationName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    	if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) {
	    	List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
	        for (MrOperation mrOperation : mrOperationList) {
	            if ("0".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType())&&StringUtils.isBlank(mrOperation.getPo0100())) {
	                saveViolationInfo(medicalRecordQuality, rule);
	                return;
	            }
	        }
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurgeryCode01_ZhongTie17
     * RULE_NAME: （主要手术）编码-1
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
      * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleSurgeryCode01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0101())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurgeryCode02_ZhongTie17
     * RULE_NAME: （主要手术）编码-2
     * RULE_INTRODUCTION: 当性别为女时，不出现以60-64开头的编码，当性别为男时，不出现65-75开头的编码
      * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleSurgeryCode02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    	String sexCode = medicalRecordQuality.getBaseInfo().getP00070001();
    	String sexDesc = dictionaryMap.get("gender").get(sexCode) ;
        if (!StringUtils.isBlank(sexCode)) {
            if (sexDesc !=null && sexDesc.contains("女")) {
                List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
                for (MrOperation mrOperation : mrOperationList) {
                    if ("1".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType())&& mrOperation.getPo0101().matches("6[0-4].*")) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }            	
            }else if (sexDesc !=null && sexDesc.contains("男")) {
                List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
                for (MrOperation mrOperation : mrOperationList) {
                    if ("1".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType()) ) {
                    	if(mrOperation.getPo0101().matches("6[5-9].*") || mrOperation.getPo0101().matches("7[0-5].*")){
	                    	saveViolationInfo(medicalRecordQuality, rule);
	                        return;
                    	}
                    }
                }            	
            }
        }

    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationCode01_ZhongTie17
     * RULE_NAME: （主要操作）编码-1
     * RULE_INTRODUCTION: 有手术操作的患者，必填
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOperationCode01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
            if ("0".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType())&&StringUtils.isBlank(mrOperation.getPo0101())) {
                saveViolationInfo(medicalRecordQuality, rule);
                return;
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationCode02_ZhongTie17
     * RULE_NAME: （主要操作）编码-2
     * RULE_INTRODUCTION: 当性别为女时，不出现以60-64开头的编码，当性别为男时，不出现65-75开头的编码
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOperationCode02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    	String sexCode = medicalRecordQuality.getBaseInfo().getP00070001();
    	String sexDesc = dictionaryMap.get("gender").get(sexCode) ;
        if (!StringUtils.isBlank(sexCode)) {
            if (sexDesc !=null && sexDesc.contains("女")) {
                List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
                for (MrOperation mrOperation : mrOperationList) {
                    if ("0".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType())&& mrOperation.getPo0101().matches("6[0-4].*")) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }            	
            }else if (sexDesc !=null && sexDesc.contains("男")) {
                List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
                for (MrOperation mrOperation : mrOperationList) {
                    if ("0".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType()) ) {
                    	if(mrOperation.getPo0101().matches("6[5-9].*") || mrOperation.getPo0101().matches("7[0-5].*")){
	                    	saveViolationInfo(medicalRecordQuality, rule);
	                        return;
                    	}
                    }
                }            	
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherDiagnosisName_ZhongTie17
     * RULE_NAME: 其他诊断名称
     * RULE_INTRODUCTION: 不能和主要诊断重复出现
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherDiagnosisName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        List<MrDiagnose> diagnoseOther = new ArrayList<MrDiagnose>();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("O".equals(diagnose.getPdType()) && !StringUtils.isBlank(diagnose.getPd0100())) {
            	diagnoseOther.add(diagnose);
            }
        }
        if(null != diagnoseOther && diagnoseOther.size()>0){
        	for (MrDiagnose diagnose : diagnoseOther) {
            	for (MrDiagnose diagnoseMain : diagnoseList) {
	            	if ("M".equals(diagnoseMain.getPdType()) && !StringUtils.isBlank(diagnoseMain.getPd0100())) {
	                	if(diagnose.getPd0100().equals(diagnoseMain.getPd0100())){
		            		saveViolationInfo(medicalRecordQuality, rule);
		                	return;
	                	}
	                }
            	}
        	}
        }
    }   
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherDiagnosis01_ZhongTie17
     * RULE_NAME: （其他出院诊断）编码-1
     * RULE_INTRODUCTION: 编码范围应为：A～U开头和Z开头的编码；不包括字母V、W、X、Y开头的编码
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherDiagnosis01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("O".equals(diagnose.getPdType())) {
                String diagCode = diagnose.getPd0101();
                if (!StringUtils.isBlank(diagCode)) {
                    if (!(diagCode.substring(0, 1).matches("[A-U]") || "Z".equals(diagCode.substring(0, 1)))) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-OtherDiagnosis02_ZhongTie17
     * RULE_NAME: （其他出院诊断）编码-2
     * RULE_INTRODUCTION: 当主要诊断或者其它诊断编码出现O80-O84编码，且无流产结局编码出现O00-O08编码时，其它诊断编码必须有分娩结局编码Z37
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherDiagnosis02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        List<String> diagCodes = new ArrayList<>();
        List<String> otherDiagCodes = new ArrayList<>();
        for (MrDiagnose diagnose : diagnoseList) {
            diagCodes.add(diagnose.getPd0101());
            if ("O".equals(diagnose.getPdType())) {
                otherDiagCodes.add(diagnose.getPd0101());
            }
        }

        boolean flag1 = false;
        boolean flag2 = true;
        for (String diagCode : diagCodes) {
            if (!StringUtils.isBlank(diagCode) && diagCode.matches("O8[0-4].*")) {
                flag1 = true;
                break;
            }
        }
        for (String diagCode : diagCodes) {
            if (!StringUtils.isBlank(diagCode) && diagCode.matches("O0[0-8].*")) {
                flag2 = false;
                break;
            }
        }
        if (flag1 && flag2) {
            for (String otherDiagCode : otherDiagCodes) {
                if (!StringUtils.isBlank(otherDiagCode) && otherDiagCode.matches("Z37.*")) {
                    return;
                }
            }
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionConditionDesc_ZhongTie17
     * RULE_NAME: （主要出院诊断）入院病情描述
     * RULE_INTRODUCTION: 必填项
     *
     * @Author: chenhanlin
     * @Date: 2018/8/01 10:36
     */
    private void ruleAdmissionConditionDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("M".equals(diagnose.getPdType())) {
                if (StringUtils.isBlank(diagnose.getPd0200())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdmissionConditionCode_ZhongTie17
     * RULE_NAME: （主要出院诊断）入院病情编码
     * RULE_INTRODUCTION: 必填项，填写1时，首页背面入院后确诊日期为入院当日或第二日
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAdmissionConditionCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            String diagTypeCode = diagnose.getPdType();
            if ("M".equals(diagTypeCode)) {
                if (StringUtils.isBlank(diagnose.getPd0201())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }else if("1".equals(diagnose.getPd0201())){//1.危 2.急 3.一般
                	int days = differentDays(medicalRecordQuality.getIpinfo().getP00250000(),medicalRecordQuality.getIpinfo().getP00390000());
                	if(days != 0 && days != 1){
                		 saveViolationInfo(medicalRecordQuality, rule);
                         return;
                	}
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-BeforeCraniocerebralTrauma_ZhongTie17
     * RULE_NAME: （入院前）颅脑损伤时间
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleBeforeCraniocerebralTrauma_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

    }

    /**
     * Annotation:
     * RULE_CODE: RULE-AfterCraniocerebralTrauma_ZhongTie17
     * RULE_NAME: （入院后）颅脑损伤时间
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleAfterCraniocerebralTrauma_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIncisionHealingLevel_ZhongTie17
     * RULE_NAME: （主要手术）切口愈合等级编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleSurseryIncisionHealingLevel_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0801())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIncisionHealingLevel_ZhongTie17
     * RULE_NAME: （主要操作）切口愈合等级编码
     * RULE_INTRODUCTION: 有手术操作的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOperationIncisionHealingLevel_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
            if ("0".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType())&&StringUtils.isBlank(mrOperation.getPo0801())) {
                saveViolationInfo(medicalRecordQuality, rule);
                return;
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherSurseryName_ZhongTie17
     * RULE_NAME: （其他手术）名称
     * RULE_INTRODUCTION: 有的要填写具体手术名称，无则在手术名称对应行中划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherSurseryName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0100())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherOperationName_ZhongTie17
     * RULE_NAME: （其他操作）名称
     * RULE_INTRODUCTION: 有的要填写具体操作名称，无则在操作名称对应行中划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherOperationName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0100())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherSurseryCode_ZhongTie17
     * RULE_NAME: （其他手术）编码
     * RULE_INTRODUCTION: 有的要填写具体手术名称，无则在手术名称对应行中划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherSurseryCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0101())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OtherOperationCode_ZhongTie17
     * RULE_NAME: （其他操作）编码
     * RULE_INTRODUCTION: 有的要填写具体操作名称，无则在操作名称对应行中划-
     * @Author: qiaoyilong
     * @Date: 2019/1/06 10:36
     */
    private void ruleOtherOperationCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("O".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0101())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PathologicalDiagnosis01_ZhongTie17
     * RULE_NAME: 病理诊断描述
     * RULE_INTRODUCTION: 必填项
     * PS: 即使不做病理，也应该录入 - （短横线）
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void rulePathologicalDiagnosis01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400101())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PathologicalDiagnosis02_ZhongTie17
     * RULE_NAME: 病理诊断描述
     * RULE_INTRODUCTION: 有病理号必须填写病理诊断
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void rulePathologicalDiagnosis02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400100())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400200())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400300())) {
        	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400101())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PathologicalCode_ZhongTie17
     * RULE_NAME: 病理诊断编码
     * RULE_INTRODUCTION: 必填项
     * PS: 即使不做病理，也应该录入 - （短横线）
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void rulePathologicalCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400401())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PathologicalDiagnosisCode_ZhongTie17
     * RULE_NAME: 病理诊断编码
     * RULE_INTRODUCTION: M800-M998之间  且  主要诊断为C00-D48编码的必填
     * PS: 即使不做病理，也应该录入 - （短横线）
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void rulePathologicalDiagnosisCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        //如果不为空，则应在M800-M998之间
    	if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400401())) {
    		if( !medicalRecordQuality.getIpinfo().getP00400401().matches("^M8[0-9]{2}.*\\w*$") && !medicalRecordQuality.getIpinfo().getP00400401().matches("^M9[0-9][0-8].*\\w*$")){
    			saveViolationInfo(medicalRecordQuality, rule);
    		}else{
    	        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
    	        for (MrDiagnose diagnose : diagnoseList) {
    	            if ("M".equals(diagnose.getPdType())) {//主要诊断为C00-D48编码的必填
    	            	if (diagnose.getPd0101().matches("^C[0-9]{2}.*\\w*$")||( diagnose.getPd0101().matches("^D[0-4][0-9].*\\w*$") && !diagnose.getPd0101().matches("^D49.*\\w*$") )) {
    	                	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400401())) {
    		                	saveViolationInfo(medicalRecordQuality, rule);
    		                    return;
    	                	}
    	                }
    	            }
    	        }
    		}
        }
    }
    /** 
     * Annotation:
     * RULE_CODE: RULE-SurgeryDate_ZhongTie17
     * RULE_NAME: （主要手术）日期
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurgeryDate_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&mrOperation.getPo0200() == null) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationDate_ZhongTie17
     * RULE_NAME: （主要操作）日期
     * RULE_INTRODUCTION: 有手术操作的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationDate_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
            if ("0".equals(mrOperation.getPo1400())&&"M".equals(mrOperation.getPoType())&&mrOperation.getPo0200() == null) {
                saveViolationInfo(medicalRecordQuality, rule);
                return;
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryAnesthesia_ZhongTie17
     * RULE_NAME: （主要手术）麻醉方式编码
     * RULE_INTRODUCTION: 有“麻醉费”的患者，麻醉方式必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryAnesthesia_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0701())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationAnesthesia_ZhongTie17
     * RULE_NAME: （主要操作）麻醉方式编码
     * RULE_INTRODUCTION: 有手术或操作的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationAnesthesia_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if ("0".equals(mrOperation.getPo1400()) || "1".equals(mrOperation.getPo1400()) ){
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0701())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicDiagnosisDescribe_ZhongTie17
     * RULE_NAME: 门急诊诊断描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleClinicDiagnosisDescribe_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if ( StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00940001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicDiagnosisCode_ZhongTie17
     * RULE_NAME: 门急诊诊断编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleClinicDiagnosisCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00940002()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicDiagnosis_ZhongTie17
     * RULE_NAME: 门急诊诊断编码
     * RULE_INTRODUCTION: 编码范围应为：A～U开头和Z开头的编码；不包括字母V、W、X、Y开头的编码
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleClinicDiagnosis_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00940002())) {
            String opDiagnosisCode = medicalRecordQuality.getIpinfo().getP00940002();

//            if (opDiagnosisCode.matches(DASH_REGEX_STR)) return; // 病案首页允许录入短横线代表空，此时不算违规
            if(StringUtils.hasLength(opDiagnosisCode)){
                if (!(opDiagnosisCode.substring(0, 1).matches("[A-U]") || "Z".equals(opDiagnosisCode.substring(0, 1)))) {
                    saveViolationInfo(medicalRecordQuality, rule);
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DrugAllergy_ZhongTie17
     * RULE_NAME: 有无药物过敏
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleDrugAllergy_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00510000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AllergicDrug_ZhongTie17
     * RULE_NAME: 过敏药物
     * RULE_INTRODUCTION: 一定条件下必填，患者有药物过敏，则过敏药物必填。
     * PS: 1-无   2-有
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleAllergicDrug_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 1无；2有
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00510000()) && "2".equals(medicalRecordQuality.getIpinfo().getP00510000())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00520000())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Autopsy_ZhongTie17
     * RULE_NAME: 死亡患者是否尸检
     * RULE_INTRODUCTION: 一定条件下必填，有“尸体料理费”的患者，“离院方式”或“疗效”为“死亡”的患者，“死亡患者尸检”必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleAutopsy_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 标准病案首页无“尸体料理费”，只校验离院方式,无法判断“疗效”为“死亡”
        if ("5".equals(medicalRecordQuality.getIpinfo().getP00620001())) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00530000())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-BloodTypeCode_ZhongTie17
     * RULE_NAME: ABO血型编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleBloodTypeCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00570001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

      /**
     * Annotation:
     * RULE_CODE: RULE-BloodTypeDesc_ZhongTie17
     * RULE_NAME: ABO血型描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleBloodTypeDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00570000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIAssistantDesc_ZhongTie17
     * RULE_NAME: （主要手术）Ⅰ助描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryIAssistantDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankDesc(mrOperation.getPo0500()) ) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIAssistantCode_ZhongTie17
     * RULE_NAME: （主要手术）Ⅰ助编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryIAssistantCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankCode(mrOperation.getPo0501())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIAssistantDesc_ZhongTie17
     * RULE_NAME: （主要操作）Ⅰ助描述
     * RULE_INTRODUCTION: 有手术或操作的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationIAssistantDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if( ( "0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400()) )&& "M".equals(mrOperation.getPoType())){
                if ("0".equals(mrOperation.getPo1400())&&isBlankDesc(mrOperation.getPo0500()) ) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIAssistantCode_ZhongTie17
     * RULE_NAME: （主要操作）Ⅰ助编码
     * RULE_INTRODUCTION: 有手术或操作的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationIAssistantCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if( ( "0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400()) )&& "M".equals(mrOperation.getPoType())){
                if ("0".equals(mrOperation.getPo1400())&&isBlankCode(mrOperation.getPo0501())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InjuryAndPoisingDescribeDesc_ZhongTie17
     * RULE_NAME: 损伤中毒的外部原因描述
     * RULE_INTRODUCTION: 主要诊断填写为损伤中毒疾病时必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleInjuryAndPoisingDescribeDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("M".equals(diagnose.getPdType())) {//主要诊断填写为损伤中毒疾病时必填项
                if (diagnose.getPd0101().matches("损伤中毒*")) {
                	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00900000())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        break;
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InjuryAndPoisingDescribeCode_ZhongTie17
     * RULE_NAME: 损伤中毒的外部原因编码
     * RULE_INTRODUCTION: 主要诊断填写为损伤中毒疾病时必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleInjuryAndPoisingDescribeCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if ("M".equals(diagnose.getPdType())) {//主要诊断填写为损伤中毒疾病时必填项
                if (diagnose.getPd0101().matches("损伤中毒*")) {
                	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00900001())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        break;
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InjuryAndPoising_ZhongTie17
     * RULE_NAME: 损伤中毒的外部原因编码
     * RULE_INTRODUCTION: ICD-10编码范围：V、W、X、Y开头的 主要诊断为S、T开头的编码必须填
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleInjuryAndPoising_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00900001())) {
            String damagePoisonIcdCd = medicalRecordQuality.getIpinfo().getP00900001();
            if (damagePoisonIcdCd.matches("^[-—]+$")) {//如果是多个-或中文—不违规
            //编码范围：V、W、X、Y开头的
            }else if (!"V,W,X,Y".contains(damagePoisonIcdCd.substring(0, 1))) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }else{
            //主要诊断为S、T开头的编码必须填
            List<MrDiagnose> mrDiagnoseList = medicalRecordQuality.getDiagnose() ;
            for (MrDiagnose mrDiagnose : mrDiagnoseList) {
                if ("M".equals(mrDiagnose.getPdType())) {
                    if (!StringUtils.isBlank(mrDiagnose.getPd0101()) &&( mrDiagnose.getPd0101().substring(0, 1).matches("S") || mrDiagnose.getPd0101().substring(0, 1).matches("T") )) {
                        if(StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00900001())){
                        	saveViolationInfo(medicalRecordQuality, rule);
                            return;
                        }
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryLevelDesc_ZhongTie17
     * RULE_NAME: （主要手术）级别描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryLevelDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())) {
                	if(StringUtils.isBlank(mrOperation.getPo0300())){
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
                	}
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryLevelCode_ZhongTie17
     * RULE_NAME: （主要手术）级别编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryLevelCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
                if ("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())) {
                	if(StringUtils.isBlank(mrOperation.getPo0301())){
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
                	}
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationLevelDesc_ZhongTie17
     * RULE_NAME: （主要操作）级别描述
     * RULE_INTRODUCTION: 有手术或操作的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationLevelDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
            if ( ("0".equals(mrOperation.getPo1400()) || "1".equals(mrOperation.getPo1400()) ) && "M".equals(mrOperation.getPoType()) ) {
            	if("0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0300())){
            		saveViolationInfo(medicalRecordQuality, rule);
            		return;
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationLevelCode_ZhongTie17
     * RULE_NAME: （主要操作）级别编码
     * RULE_INTRODUCTION: 有手术或操作的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationLevelCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
            if ( ("0".equals(mrOperation.getPo1400()) || "1".equals(mrOperation.getPo1400()) ) && "M".equals(mrOperation.getPoType()) ) {
            	if("0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0301())){
            		saveViolationInfo(medicalRecordQuality, rule);
            		return;
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-RhDesc_ZhongTie17
     * RULE_NAME: Rh血型描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleRhDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00580000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-RhCode_ZhongTie17
     * RULE_NAME: Rh血型编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleRhCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00580001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Pathology_ZhongTie17
     * RULE_NAME: 病理号（有一次住院多个标本的可能）
     * RULE_INTRODUCTION: 必填项，有病理诊断费时不可为空
     * PS: 即使不做病理，也应该录入 - （短横线）
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void rulePathology_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("bingLizdf") != null && medicalRecordQuality.getExpenseMap().get("bingLizdf") > 0) {
            if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400100())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400200())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400300())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }else if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400100())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400200())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00400300())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurserySurgeonDesc_ZhongTie17
     * RULE_NAME: （主要手术）术者描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurserySurgeonDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankDesc(mrOperation.getPo0400()) ) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }            		
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurserySurgeonCode_ZhongTie17
     * RULE_NAME: （主要手术）术者编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurserySurgeonCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankCode(mrOperation.getPo0401())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }            		
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationSurgeonDesc_ZhongTie17
     * RULE_NAME: （主要操作）术者描述
     * RULE_INTRODUCTION: 有“手术或操作”的患者，（主要操作）术者必填
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationSurgeonDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if("0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400())){
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&isBlankDesc(mrOperation.getPo0400()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationSurgeonCode_ZhongTie17
     * RULE_NAME: （主要操作）术者编码
     * RULE_INTRODUCTION: 有“手术或操作”的患者，（主要操作）术者必填
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationSurgeonCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if("0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400())){
                if ("M".equals(mrOperation.getPoType())&&"0".equals(mrOperation.getPo1400())&&isBlankCode(mrOperation.getPo0401())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryAnesthetistDesc_ZhongTie17
     * RULE_NAME: （主要手术）麻醉医师描述
     * RULE_INTRODUCTION: 有“麻醉费”的患者，麻醉医师必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryAnesthetistDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
	                if (StringUtils.isBlank(mrOperation.getPo0900()) ) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryAnesthetistCode_ZhongTie17
     * RULE_NAME: （主要手术）麻醉医师编码
     * RULE_INTRODUCTION: 有“麻醉费”的患者，麻醉医师必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryAnesthetistCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
	                if (StringUtils.isBlank(mrOperation.getPo0901())) {
	                    saveViolationInfo(medicalRecordQuality, rule);
	                    return;
	                }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationAnesthetistDesc_ZhongTie17
     * RULE_NAME: （主要操作）麻醉医师描述
     * RULE_INTRODUCTION: 有“手术或操作”的患者，（主要操作）麻醉医师必填。没有麻醉医师划-
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationAnesthetistDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if( ("0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400()) ) && "M".equals(mrOperation.getPoType()) ){
                if ("0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0900()) ) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationAnesthetistCode_ZhongTie17
     * RULE_NAME: （主要操作）麻醉医师编码
     * RULE_INTRODUCTION: 有“手术或操作”的患者，（主要操作）麻醉医师必填。没有麻醉医师划-
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationAnesthetistCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if( ("0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400()) ) && "M".equals(mrOperation.getPoType()) ){
                if ( "0".equals(mrOperation.getPo1400())&&StringUtils.isBlank(mrOperation.getPo0901())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIIAssistantDesc_ZhongTie17
     * RULE_NAME: （主要操作）Ⅱ助描述
     * RULE_INTRODUCTION: 有“手术或操作”的患者，（主要操作）Ⅱ助必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationIIAssistantDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if( ( "0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400()) ) && "M".equals(mrOperation.getPoType()) ){
                if ("0".equals(mrOperation.getPo1400())&&isBlankDesc(mrOperation.getPo0600()) ) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationIIAssistantCode_ZhongTie17
     * RULE_NAME: （主要操作）Ⅱ助编码
     * RULE_INTRODUCTION: 有“手术或操作”的患者，（主要操作）Ⅱ助必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleOperationIIAssistantCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
        	if( ( "0".equals(mrOperation.getPo1400())||"1".equals(mrOperation.getPo1400()) ) && "M".equals(mrOperation.getPoType()) ){
                if ("0".equals(mrOperation.getPo1400())&&isBlankCode(mrOperation.getPo0601())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIIAssistantDesc_ZhongTie17
     * RULE_NAME: （主要手术）Ⅱ助描述
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryIIAssistantDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankDesc(mrOperation.getPo0600()) ) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SurseryIIAssistantCode_ZhongTie17
     * RULE_NAME: （主要手术）Ⅱ助编码
     * RULE_INTRODUCTION: 有“手术治疗费”的患者，必填。
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleSurseryIIAssistantCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) {
            List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
            for (MrOperation mrOperation : mrOperationList) {
            	if("M".equals(mrOperation.getPoType())&&"1".equals(mrOperation.getPo1400())){
                    if (isBlankCode(mrOperation.getPo0601())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
            	}
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-VentilatorUsageTime_ZhongTie17
     * RULE_NAME: 呼吸机使用时间
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleVentilatorUsageTime_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getMrAppendPage().getP90120201() == null || medicalRecordQuality.getMrAppendPage().getP90120201()<0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Efficacy01_ZhongTie17
     * RULE_NAME: （主要出院诊断）疗效-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleEfficacy01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrDiagnose> mrDiagnoseList = medicalRecordQuality.getDiagnose() ;
        for (MrDiagnose mrDiagnose : mrDiagnoseList) {
            if ("M".equals(mrDiagnose.getPdType())) {
                if (StringUtils.isBlank(mrDiagnose.getPd0202())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-Efficacy02_ZhongTie17
     * RULE_NAME: （主要出院诊断）疗效-2
     * RULE_INTRODUCTION: 有“尸体料理费”的患者，“疗效”只能为“死亡”，  死亡患者尸检填1的，主要诊断出院时情况只能选4
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleEfficacy02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 有“尸体料理费”的患者，“疗效”只能为“死亡”， T_MEDICALRECORD 表中无此字段——（主要出院诊断）疗效-2 标准病案无此项
    	
    	//死亡患者尸检填1的，主要诊断出院时情况只能选4
    	if("1".equals(medicalRecordQuality.getIpinfo().getP00530000())){
              List<MrDiagnose> mrDiagnoseList = medicalRecordQuality.getDiagnose() ;
	          for (MrDiagnose mrDiagnose : mrDiagnoseList) {
	              if ("M".equals(mrDiagnose.getPdType())) {
	                  if (!"4".equals(mrDiagnose.getPd0300())) {
	                      saveViolationInfo(medicalRecordQuality, rule);
	                     return;
	                  }
	              }
	          }
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts01_ZhongTie17
     * RULE_NAME: 住院总费用-1
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleIPCosts01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() == null || medicalRecordQuality.getIpinfo().getP00800000()<= 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts02_ZhongTie17
     * RULE_NAME: 住院总费用-2
     * RULE_INTRODUCTION: 费用不能小于5，不能大于1000000
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleIPCosts02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() != null) {
            double costAmount = medicalRecordQuality.getIpinfo().getP00800000().doubleValue();
            if (costAmount < 5 || costAmount > 1000000) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }else{
        	saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts03_ZhongTie17
     * RULE_NAME: 住院总费用-3
     * RULE_INTRODUCTION: 分项费用全部有值时，住院总费用应等于各分项费用（除自付金额,临床物理治疗费,麻醉费,手术费,抗菌药物费用外）之和。
     * P782=P752+P754+P755+P756+P757+P758+P759+P760+P761+P763+P767+P768+P769+P771+P772+P773+P774+P775+P776+P777+P778+P779+P780+P781
     * <p>
     * 住院总费用（P782）
     * 一般医疗服务费（P752）
     * 一般治疗操作费（P754）
     * 护理费（P755）
     * 综合医疗服务类其他费用（P756）
     * 病理诊断费（P757）
     * 实验室诊断费（P758）
     * 影像学诊断费（P759）
     * 临床诊断项目费（P760）
     * 非手术治疗项目费（P761）
     * 手术治疗费（P763）
     * 康复费（P767）
     * 中医治疗费（P768）
     * 西药费（P769）
     * 中成药费（P771）
     * 中草药费（P772）
     * 血费（P773）
     * 白蛋白类制品费（P774）
     * 球蛋白类制品费（P775）
     * 凝血因子类制品费（P776）
     * 细胞因子类制品费（P777）
     * 检查用一次性医用材料费（P778）
     * 治疗用一次性医用材料费（P779）
     * 手术用一次性医用材料费（P780）
     * 其他费（P781）
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleIPCosts03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() != null) {//住院总费用
        	
            if ((medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") != null && medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") > 0) // 一般医疗服务费（P752）
                    && (medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") != null && medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") > 0) // 一般治疗操作费（P754）
                    && (medicalRecordQuality.getExpenseMap().get("huLif") != null && medicalRecordQuality.getExpenseMap().get("huLif") > 0) // 护理费（P755）
                    && (medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") != null && medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") > 0) // 综合医疗服务类其他费用（P756）
                    && (medicalRecordQuality.getExpenseMap().get("bingLizdf") != null && medicalRecordQuality.getExpenseMap().get("bingLizdf") >0) // 病理诊断费（P757）
                    && (medicalRecordQuality.getExpenseMap().get("shiYanShizdf") != null && medicalRecordQuality.getExpenseMap().get("shiYanShizdf") > 0) // 实验室诊断费（P758）
                    && (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) // 影像学诊断费（P759）
                    && (medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") > 0) // 临床诊断项目费（P760）
                    && (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") > 0) // 非手术治疗项目费（P761）
                    && (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) // 手术治疗费（P763）
                    && (medicalRecordQuality.getExpenseMap().get("kangFuf") != null && medicalRecordQuality.getExpenseMap().get("kangFuf") > 0) // 康复费（P767）
                    && (medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") != null && medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") > 0) // 中医治疗费（P768）
                    && (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("xiYaof") > 0) // 西药费（P769）
                    && (medicalRecordQuality.getExpenseMap().get("zhongChengYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongChengYaof") > 0) // 中成药费（P771）
                    && (medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") > 0) // 中草药费（P772）
                    && (medicalRecordQuality.getExpenseMap().get("xuef") != null && medicalRecordQuality.getExpenseMap().get("xuef") > 0) // 血费（P773）
                    && (medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") > 0) // 白蛋白类制品费（P774）
                    && (medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") > 0) // 球蛋白类制品费（P775）
                    && (medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") > 0) // 凝血因子类制品费（P776）
                    && (medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") > 0) // 细胞因子类制品费（P777）
                    && (medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") > 0) // 检查用一次性医用材料费（P778）
                    && (medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") > 0) // 治疗用一次性医用材料费（P779）
                    && (medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") > 0) // 手术用一次性医用材料费（P780）
                    && (medicalRecordQuality.getExpenseMap().get("qiTaf") != null && (medicalRecordQuality.getExpenseMap().get("qiTaf")) > 0) // 其他费（P781）
                    ) {
            	
                BigDecimal costAmount = new BigDecimal(medicalRecordQuality.getIpinfo().getP00800000().toString());
                BigDecimal sumFee =  new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf").toString())
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("huLif").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("bingLizdf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("shiYanShizdf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuzlf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("kangFuf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiYaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongChengYaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongCaoYaof").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("xuef").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf").toString()))
                        .add( new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiTaf").toString()));
                if (costAmount.compareTo(sumFee) != 0) {
                    saveViolationInfo(medicalRecordQuality, rule);
                }
            }
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-IPCosts04_ZhongTie17
     * RULE_NAME: 住院总费用-4
     * RULE_INTRODUCTION: 分项费用部分有值时，住院总费用应大于等于各分项费用（除自付金额,临床物理治疗费,麻醉费,手术费,抗菌药物费用外）之和。
     * P782≥P752+P754+P755+P756+P757+P758+P759+P760+P761+P763+P767+P768+P769+P771+P772+P773+P774+P775+P776+P777+P778+P779+P780+P781
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleIPCosts04_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00800000() != null) {
            BigDecimal costAmount = new BigDecimal(medicalRecordQuality.getIpinfo().getP00800000().toString());
            BigDecimal sumFee = new BigDecimal("0");
 
            if (medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") != null && medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") > 0) { // 一般医疗服务费（P752）           
            	sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") != null && medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") > 0) { // 一般治疗操作费（P754）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("huLif") != null && medicalRecordQuality.getExpenseMap().get("huLif") > 0) { // 护理费（P755）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("huLif").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") != null && medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") > 0) { // 综合医疗服务类其他费用（P756）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("bingLizdf") != null && medicalRecordQuality.getExpenseMap().get("bingLizdf") > 0) { // 病理诊断费（P757）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("bingLizdf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("shiYanShizdf") != null && medicalRecordQuality.getExpenseMap().get("shiYanShizdf") > 0) { // 实验室诊断费（P758）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("shiYanShizdf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") > 0) { // 影像学诊断费（P759）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") > 0) { // 临床诊断项目费（P760）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") > 0) { // 非手术治疗项目费（P761）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") > 0) { // 手术治疗费（P763）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuzlf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("kangFuf") != null && medicalRecordQuality.getExpenseMap().get("kangFuf") > 0) { // 康复费（P767）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("kangFuf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") != null && medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") > 0) { // 中医治疗费（P768）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("xiYaof") > 0) { // 西药费（P769）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiYaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhongChengYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongChengYaof") > 0) { // 中成药费（P771）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongChengYaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") > 0) { // 中草药费（P772）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhongCaoYaof").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("xuef") != null && medicalRecordQuality.getExpenseMap().get("xuef") > 0) { // 血费（P773）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("xuef").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") > 0) { // 白蛋白类制品费（P774）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") > 0) { // 球蛋白类制品费（P775）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") > 0) { // 凝血因子类制品费（P776）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") > 0) { // 细胞因子类制品费（P777）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") > 0) { // 检查用一次性医用材料费（P778）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") > 0) { // 治疗用一次性医用材料费（P779）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf").toString()));
            }                                             
            if (medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") > 0) { // 手术用一次性医用材料费（P780）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf").toString()));
            }
            if (medicalRecordQuality.getExpenseMap().get("qiTaf") != null && (medicalRecordQuality.getExpenseMap().get("qiTaf")) > 0) { // 其他费（P781）
                sumFee = sumFee.add(new BigDecimal(medicalRecordQuality.getExpenseMap().get("qiTaf").toString()));
            }
           
            if (costAmount.compareTo(sumFee) == -1) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeSynthetical01_ZhongTie17
     * RULE_NAME: 综合医疗服务类-一般医疗服务费(1)
     * RULE_INTRODUCTION: 综合医疗服务类-一般医疗服务费(1)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeSynthetical01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") != null && medicalRecordQuality.getExpenseMap().get("yiBanYiLiaofwf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeSynthetical02_ZhongTie17
     * RULE_NAME: 综合医疗服务类-一般治疗操作费(2)
     * RULE_INTRODUCTION: 综合医疗服务类-一般治疗操作费(2)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeSynthetical02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") != null && medicalRecordQuality.getExpenseMap().get("yiBanZhiLiaoczf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeSynthetical03_ZhongTie17
     * RULE_NAME: 综合医疗服务类-护理费(3)
     * RULE_INTRODUCTION: 综合医疗服务类-护理费(3)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeSynthetical03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("huLif") != null && medicalRecordQuality.getExpenseMap().get("huLif") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeSynthetical04_ZhongTie17
     * RULE_NAME: 综合医疗服务类-其他费用(4)
     * RULE_INTRODUCTION: 综合医疗服务类-其他费用(4)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeSynthetical04_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") != null && medicalRecordQuality.getExpenseMap().get("zongHeYiLiaofwfQiTaf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeDiagnose01_ZhongTie17
     * RULE_NAME: 诊断类-实验室诊断费(6)
     * RULE_INTRODUCTION: 诊断类-实验室诊断费(6)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeDiagnose01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shiYanShizdf") != null && medicalRecordQuality.getExpenseMap().get("shiYanShizdf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }

    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeDiagnose02_ZhongTie17
     * RULE_NAME: 诊断类-影像学诊断费(7)
     * RULE_INTRODUCTION: 诊断类-影像学诊断费(7)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeDiagnose02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") != null && medicalRecordQuality.getExpenseMap().get("yingXiangXuezdf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeDiagnose03_ZhongTie17
     * RULE_NAME: 诊断类-病理诊断费(5)
     * RULE_INTRODUCTION: 诊断类-病理诊断费(5)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeDiagnose03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("bingLizdf") != null && medicalRecordQuality.getExpenseMap().get("bingLizdf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeDiagnose04_ZhongTie17
     * RULE_NAME: 诊断类-临床诊断项目费(8)
     * RULE_INTRODUCTION: 诊断类-临床诊断项目费(8)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeDiagnose04_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangZhenDuanxmf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HF09ClinicPhysiotherapyFee_ZhongTie17
     * RULE_NAME: 治疗类-9-临床物理治疗费
     * RULE_INTRODUCTION: 治疗类-9-临床物理治疗费：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHF09ClinicPhysiotherapyFee_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") != null && medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HF10OperationFee_ZhongTie17
     * RULE_NAME: 治疗类-10-手术费
     * RULE_INTRODUCTION: 治疗类-10-手术费：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHF10OperationFee_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuf") != null && medicalRecordQuality.getExpenseMap().get("shouShuf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HF10AnesthesiaFee_ZhongTie17
     * RULE_NAME: 治疗类-10-麻醉费
     * RULE_INTRODUCTION: 治疗类-10-麻醉费：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHF10AnesthesiaFee_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("maZuif") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeTreat01_ZhongTie17
     * RULE_NAME: 治疗类-手术治疗费(10)
     * RULE_INTRODUCTION: 治疗类-手术治疗费(10)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeTreat01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("shouShuzlf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeTreat02_ZhongTie17
     * RULE_NAME: 治疗类-非手术治疗项目费(9)
     * RULE_INTRODUCTION: 治疗类-非手术治疗项目费(9)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeTreat02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee09IITreat03_ZhongTie17
     * RULE_NAME: 非手术治疗项目费
     * RULE_INTRODUCTION: 非手术治疗项目费必须大于等于临床物理治疗费
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFee09IITreat03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") != null && medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") != null) {
        	BigDecimal fzllffssf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf").toString());
        	BigDecimal fzllfwlzwlf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf").toString());
            if (fzllffssf.compareTo(fzllfwlzwlf) < 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        } else if (medicalRecordQuality.getExpenseMap().get("feiShouShuZhiLiaoxmf") == null && medicalRecordQuality.getExpenseMap().get("linChuangWuLizlf") != null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee10IITreat04_ZhongTie17
     * RULE_NAME: 手术治疗费
     * RULE_INTRODUCTION: 手术治疗费必须大于等于麻醉费与手术费之和
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFee10IITreat04_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") != null && medicalRecordQuality.getExpenseMap().get("maZuif") != null && medicalRecordQuality.getExpenseMap().get("shouShuf") != null) {
        	BigDecimal fzllfssf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuzlf").toString()); // 手术治疗费
            BigDecimal fzllfmzf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("maZuif").toString()); // 麻醉费
            BigDecimal fzllfsszlf = new BigDecimal(medicalRecordQuality.getExpenseMap().get("shouShuf").toString()); // 手术费
            if (fzllfssf.compareTo(fzllfmzf.add(fzllfsszlf)) < 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        } else if (medicalRecordQuality.getExpenseMap().get("shouShuzlf") == null && (medicalRecordQuality.getExpenseMap().get("maZuif") != null || medicalRecordQuality.getExpenseMap().get("shouShuf") != null)) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeRecovery_ZhongTie17
     * RULE_NAME: 康复类-康复费(11)
     * RULE_INTRODUCTION: 康复类-康复费(11)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeRecovery_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("kangFuf") != null && medicalRecordQuality.getExpenseMap().get("kangFuf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeChineseDoctor_ZhongTie17
     * RULE_NAME: 中医类-中医治疗费(12)
     * RULE_INTRODUCTION: 中医类-中医治疗费(12)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeChineseDoctor_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") != null && medicalRecordQuality.getExpenseMap().get("zhongYiZhiLiaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeChineseMedicine01_ZhongTie17
     * RULE_NAME: 中药类-中草药费(15)
     * RULE_INTRODUCTION: 中药类-中草药费(15)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeChineseMedicine01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongCaoYaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeChineseMedicine02_ZhongTie17
     * RULE_NAME: 中药类-中成药费(14)
     * RULE_INTRODUCTION: 中药类-中成药费(14)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeChineseMedicine02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhongChengYaof") != null && medicalRecordQuality.getExpenseMap().get("zhongChengYaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HF13AntibioticsFee_ZhongTie17
     * RULE_NAME: 西药类-13-抗菌药物费用
     * RULE_INTRODUCTION: 西药类-13-抗菌药物费用：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHF13AntibioticsFee_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") != null && medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeWesternMedicine01_ZhongTie17
     * RULE_NAME: 西药类-西药费(13)
     * RULE_INTRODUCTION: 西药类-西药费(13)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeWesternMedicine01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("xiYaof") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFee13IIWesternMedicine02_ZhongTie17
     * RULE_NAME: 西药费
     * RULE_INTRODUCTION: 西药费必须大于等于抗菌药物费用
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFee13IIWesternMedicine02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xiYaof") != null && medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") != null) {
            Double fxyf = medicalRecordQuality.getExpenseMap().get("xiYaof");
            Double fxylgjf = medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy");
            if (fxyf.compareTo(fxylgjf) < 0) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        } else if (medicalRecordQuality.getExpenseMap().get("xiYaof") == null && medicalRecordQuality.getExpenseMap().get("kangJunYaoWufy") != null) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeBlood01_ZhongTie17
     * RULE_NAME: 血液和血液制品类-球蛋白类制品费(18)
     * RULE_INTRODUCTION: 血液和血液制品类-球蛋白类制品费(18)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeBlood01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("qiuDanBaiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeBlood02_ZhongTie17
     * RULE_NAME: 血液和血液制品类-白蛋白类制品费(17)
     * RULE_INTRODUCTION: 血液和血液制品类-白蛋白类制品费(17)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeBlood02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("baiDanDaiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeBlood03_ZhongTie17
     * RULE_NAME: 血液和血液制品类-血费(16)
     * RULE_INTRODUCTION: 血液和血液制品类-血费(16)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/07 10:36
     */
    private void ruleHospitalFeeBlood03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xuef") != null && medicalRecordQuality.getExpenseMap().get("xuef") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeBlood04_ZhongTie17
     * RULE_NAME: 血液和血液制品类-细胞因子类制品费(20)
     * RULE_INTRODUCTION: 血液和血液制品类-细胞因子类制品费(20)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleHospitalFeeBlood04_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("xiBaoYinZiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeBlood05_ZhongTie17
     * RULE_NAME: 血液和血液制品类-凝血因子类制品费(19)
     * RULE_INTRODUCTION: 血液和血液制品类-凝血因子类制品费(19)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleHospitalFeeBlood05_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") != null && medicalRecordQuality.getExpenseMap().get("ningXueYinZiLeizpf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeConsumables01_ZhongTie17
     * RULE_NAME: 耗材类-检查用一次性医用材料费(21)
     * RULE_INTRODUCTION: 耗材类-检查用一次性医用材料费(21)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleHospitalFeeConsumables01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("jianChaYongycxyyclf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeConsumables02_ZhongTie17
     * RULE_NAME: 耗材类-手术用一次性医用材料费(23)
     * RULE_INTRODUCTION: 耗材类-手术用一次性医用材料费(23)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleHospitalFeeConsumables02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("shouShuYongycxyyclf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeConsumables03_ZhongTie17
     * RULE_NAME: 耗材类-治疗用一次性医用材料费(22)
     * RULE_INTRODUCTION: 耗材类-治疗用一次性医用材料费(22)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleHospitalFeeConsumables03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") != null && medicalRecordQuality.getExpenseMap().get("zhiLiaoYongycxyyclf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-HospitalFeeOther_ZhongTie17
     * RULE_NAME: 其他类-其他费(24)
     * RULE_INTRODUCTION: 其他类-其他费(24)：费用不允许小于0
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleHospitalFeeOther_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("qiTaf") != null && medicalRecordQuality.getExpenseMap().get("qiTaf") < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Payment_ZhongTie17
     * RULE_NAME: 自付费用
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void rulePayment_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getIpinfo().getP00810000() == null && medicalRecordQuality.getIpinfo().getP00810000() < 0) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnoseDate_ZhongTie17
     * RULE_NAME: 入院后确诊日期
     * RULE_INTRODUCTION: 主要诊断入院病情选1时，确诊日期应为入院当日或第二日
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiagnoseDate_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {

        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            String diagTypeCode = diagnose.getPdType();
            if ("M".equals(diagTypeCode)) {
                if("1".equals(diagnose.getPd0200())){
                	int days = differentDays(medicalRecordQuality.getIpinfo().getP00250000(),medicalRecordQuality.getIpinfo().getP00390000());
                	if(days != 0 && days != 1){
                		 saveViolationInfo(medicalRecordQuality, rule);
                         return;
                	}
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Discuss01_ZhongTie17
     * RULE_NAME: 病历讨论
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiscuss01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP00336000()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Discuss02_ZhongTie17
     * RULE_NAME: 病历讨论
     * RULE_INTRODUCTION: 有则在横线处填写具体病例讨论内容，无则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiscuss02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        //没有病历讨论内容的字段，这里质控的是 是否有病历讨论字段
    	if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP00336000()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    } 
    /**
     * Annotation:
     * RULE_CODE: RULE-SalvageAndSuccessTimes_ZhongTie17
     * RULE_NAME: 抢救次数及成功次数
     * RULE_INTRODUCTION: 有则填写，无则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleSalvageAndSuccessTimes_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
       
    	if (medicalRecordQuality.getIpinfo().getP00490000() == null && medicalRecordQuality.getIpinfo().getP00500000() == null ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InCondition_ZhongTie17
     * RULE_NAME: 入院时情况
     * RULE_INTRODUCTION: 与入院途径相一致，急诊入院时入院时情况只能为1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleInCondition_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    	//急诊入院时  入院时情况只能为1或2
    	if ("1".equals( medicalRecordQuality.getIpinfo().getP00230001() ) ) {
        	if ( !"1".equals(medicalRecordQuality.getIpinfo().getP00380001()) && !"2".equals(medicalRecordQuality.getIpinfo().getP00380001()) ) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }else{
        	if( !StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00380000()) && !StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00230000()) ){
	        	if ( !( medicalRecordQuality.getIpinfo().getP00380000() ).equals(  medicalRecordQuality.getIpinfo().getP00230000() )   ) {
	        		saveViolationInfo(medicalRecordQuality, rule);
	        	}
        	}         
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OutDiagnoseCondition_ZhongTie17
     * RULE_NAME: 主要诊断出院时情况
     * RULE_INTRODUCTION: 离院方式选4，不能选治愈；离院方式选5，只能选4
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleOutDiagnoseCondition_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        //离院方式选4，主要诊断出院时情况不能选治愈
        if ("4".equals(medicalRecordQuality.getIpinfo().getP00620001()) ) {
            List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
            for (MrDiagnose diagnose : diagnoseList) {
                if ("M".equals(diagnose.getPdType())) {//主要诊断
                    if ("1".equals(diagnose.getPd0301())) {//主要诊断出院时情况不能为治愈  1.治愈2.好转3.未愈4.死亡5.其他
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }
        //离院方式选5，只能选4
        if ("5".equals(medicalRecordQuality.getIpinfo().getP00620001()) ) {
            List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
            for (MrDiagnose diagnose : diagnoseList) {
                if ("M".equals(diagnose.getPdType())) {//主要诊断
                    if (!"4".equals(diagnose.getPd0301())) {//主要诊断出院时情况不能为治愈  1.治愈2.好转3.未愈4.死亡5.其他
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InfectCondition01_ZhongTie17
     * RULE_NAME: 医院感染情况
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleInfectCondition01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90051001()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InfectCondition02_ZhongTie17
     * RULE_NAME: 医院感染情况
     * RULE_INTRODUCTION: 选1在感染名称后面写具体疾病名称；选2在感染名称后面划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleInfectCondition02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
       //选1在感染名称后面写具体疾病名称
    	if ( "1".equals(medicalRecordQuality.getMrAppendPage().getP90051001()) ) {
    		if(StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90052000()) ){
    			saveViolationInfo(medicalRecordQuality, rule);
    		}
        }
        //选2在感染名称后面划-
     	if ( "2".equals(medicalRecordQuality.getMrAppendPage().getP90051001()) ) {
     		if( !StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90052000()) ){
     			saveViolationInfo(medicalRecordQuality, rule);
     		}
         }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-InfectName_ZhongTie17
     * RULE_NAME: 医院感染名称
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleInfectName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90052000()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnoseTrueCondition01_ZhongTie17
     * RULE_NAME: 门诊与出院诊断符合情况
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiagnoseTrueCondition01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00440000())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00440001()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnoseTrueCondition02_ZhongTie17
     * RULE_NAME: 入院与出院诊断符合情况
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiagnoseTrueCondition02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00450000())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00450001()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnoseTrueCondition03_ZhongTie17
     * RULE_NAME: 术前与术后诊断符合情况
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiagnoseTrueCondition03_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00460000())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00460001()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnoseTrueCondition04_ZhongTie17
     * RULE_NAME: 临床与病理诊断符合情况
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiagnoseTrueCondition04_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00470000())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00470001()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-DiagnoseTrueCondition05_ZhongTie17
     * RULE_NAME: 放射与病理诊断符合情况
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleDiagnoseTrueCondition05_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00480000())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00480001()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicalPathWay01_ZhongTie17
     * RULE_NAME: 实施临床路径
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleClinicalPathWay01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00330000())&&StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00330001()) ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicalPathWay02_ZhongTie17
     * RULE_NAME: 实施临床路径
     * RULE_INTRODUCTION: 选1在临床路径病种名称后面写具体疾病名称；选2在临床路径病种名称后面划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleClinicalPathWay02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	//选1在临床路径病种名称后面写具体疾病名称
    	if ("1".equals(medicalRecordQuality.getIpinfo().getP00330001()) ){
    		if(StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00330000()) ){
    			saveViolationInfo(medicalRecordQuality, rule);
    		}
        }
    	//选2在临床路径病种名称后面划-
    	if ("2".equals(medicalRecordQuality.getIpinfo().getP00330001()) ){
    		if( !StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00330000())){
    			saveViolationInfo(medicalRecordQuality, rule);
    		}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ClinicalPathWayName_ZhongTie17
     * RULE_NAME: 临床路径疾病名称
     * RULE_INTRODUCTION: 有则填写临床路径疾病名称，无则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleClinicalPathWayName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	//是否实施临床路径编码 1.是 2.否
    	if("1".equals(medicalRecordQuality.getMrAppendPage().getP90080001())){
    		//临床路径疾病名称  找不到
//        	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00330000())) {
//                saveViolationInfo(medicalRecordQuality, rule);
//            }
    	}
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SingleCase_ZhongTie17
     * RULE_NAME: 单病种
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleSingleCase_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP00335000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SevereCase01_ZhongTie17
     * RULE_NAME: 危重病人
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleSevereCase01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00910000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SevereCase02_ZhongTie17
     * RULE_NAME: 危重病人
     * RULE_INTRODUCTION: 抢救次数、成功次数有写次数，无则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleSevereCase02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {       
//    	if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00910000())) {
//            saveViolationInfo(medicalRecordQuality, rule);
//        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-SectionHead_ZhongTie17
     * RULE_NAME: 科主任
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对科主任未要求编码字典，故此处只校验文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleSectionHead_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600101())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Physician_ZhongTie17
     * RULE_NAME: 主治医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void rulePhysician_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600301())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Resident_ZhongTie17
     * RULE_NAME: 住院医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleResident_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600401())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Archiater_ZhongTie17
     * RULE_NAME: 主任（副主任）医师
     * RULE_INTRODUCTION: 必填项
     * PS: 因卫统4-1表中对医师未要求编码字典，故此处只校验文字信息
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleArchiater_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (isBlankCode(medicalRecordQuality.getIpinfo().getP00600201())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-QCDoctor_ZhongTie17
     * RULE_NAME: 质控医师
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleQCDoctor_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610100())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-AdvancedDoctor_ZhongTie17
     * RULE_NAME: 进修医师
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleAdvancedDoctor_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00600600())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ChargeNurse_ZhongTie17
     * RULE_NAME: 责任护士
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleChargeNurse_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00600500())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-QCNurse_ZhongTie17
     * RULE_NAME: 质控护士
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleQCNurse_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610200())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-QCDate_ZhongTie17
     * RULE_NAME: 质控日期
     * RULE_INTRODUCTION: 必填项，出院当日或第二日
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleQCDate_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (null == medicalRecordQuality.getIpinfo().getP00610300() ) {
            saveViolationInfo(medicalRecordQuality, rule);
        }else{
        	Date dealDate = medicalRecordQuality.getIpinfo().getP00610300();
        	Date outDate = medicalRecordQuality.getIpinfo().getP00290000();
        	//出院当日或第二日
        	if(differentDays(outDate,dealDate)!=0 && differentDays(outDate,dealDate)!=1){
        		saveViolationInfo(medicalRecordQuality, rule);
        	}
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-CaseQualityDesc_ZhongTie17
     * RULE_NAME: 病案质量描述
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleCaseQualityDesc_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610000())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-CaseQualityCode_ZhongTie17
     * RULE_NAME: 病案质量编码
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleCaseQualityCode_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00610001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Coder_ZhongTie17
     * RULE_NAME: 编码员
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleCoder_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getIpinfo().getP00600900())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PressureSore01_ZhongTie17
     * RULE_NAME: 住院患者压疮
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void rulePressureSore01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90200001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-PressureSore02_ZhongTie17
     * RULE_NAME: 住院患者压疮
     * RULE_INTRODUCTION: 选择1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void rulePressureSore02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90200001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90200001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-BloodReaction01_ZhongTie17
     * RULE_NAME: 输血反应
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleBloodReaction01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90210001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-BloodReaction02_ZhongTie17
     * RULE_NAME: 输血反应
     * RULE_INTRODUCTION: 有血费必须选择1或2   无则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleBloodReaction02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (medicalRecordQuality.getExpenseMap().get("xuef") != null && medicalRecordQuality.getExpenseMap().get("xuef") > 0) {
        	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90210001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90210001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-TransfusionReaction01_ZhongTie17
     * RULE_NAME: 输液反应
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleTransfusionReaction01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90215001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-TransfusionReaction02_ZhongTie17
     * RULE_NAME: 输液反应
     * RULE_INTRODUCTION: 有输液选择1或2，如患者住院期间没有输液，则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleTransfusionReaction02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90215001())) {
        	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90215001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90215001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationExistObject01_ZhongTie17
     * RULE_NAME: 术中异物存留
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleOperationExistObject01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90220001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-OperationExistObject02_ZhongTie17
     * RULE_NAME: 术中异物存留
     * RULE_INTRODUCTION: 如没有手术则划- 有手术选择1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleOperationExistObject02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
    	List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {           
            if ("1".equals(mrOperation.getPo1400())) {
            	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90220001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90220001())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    break;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IatrogenicPneumothorax01_ZhongTie17
     * RULE_NAME: 医源性气胸
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleIatrogenicPneumothorax01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90230001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IatrogenicPneumothorax02_ZhongTie17
     * RULE_NAME: 医源性气胸
     * RULE_INTRODUCTION: 只能选择1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleIatrogenicPneumothorax02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90230001())) {
        	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90230001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90230001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IatrogenicPunctureInjury01_ZhongTie17
     * RULE_NAME: 医源性意外穿刺伤
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleIatrogenicPunctureInjury01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90240001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IatrogenicPunctureInjury02_ZhongTie17
     * RULE_NAME: 医源性意外穿刺伤
     * RULE_INTRODUCTION: 只能选择1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleIatrogenicPunctureInjury02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90240001())) {
        	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90240001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90240001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IatrogenicAccidentalLacerationInjury01_ZhongTie17
     * RULE_NAME: 医源性意外撕裂伤
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleIatrogenicAccidentalLacerationInjury01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90250001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-IatrogenicAccidentalLacerationInjury02_ZhongTie17
     * RULE_NAME: 医源性意外撕裂伤
     * RULE_INTRODUCTION: 只能选择1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleIatrogenicAccidentalLacerationInjury02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90250001())) {
        	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90250001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90250001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Fall01_ZhongTie17
     * RULE_NAME: 医院内跌倒
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleFall01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90260001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-Fall02_ZhongTie17
     * RULE_NAME: 医院内跌倒
     * RULE_INTRODUCTION: 只能选择1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleFall02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90260001())) {
        	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90260001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90260001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-FallingBed01_ZhongTie17
     * RULE_NAME: 医院内坠床
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleFallingBed01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90270001())) {
            saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-FallingBed02_ZhongTie17
     * RULE_NAME: 医院内坠床
     * RULE_INTRODUCTION: 只能选择1或2
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleFallingBed02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if (!StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90270001())) {
        	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90270001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90270001())) {
                saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-NewbornBirthInjury_ZhongTie17
     * RULE_NAME: 新生儿产伤
     * RULE_INTRODUCTION: 其他诊断编码存在Z37时，选择1或2，其他病历划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleNewbornBirthInjury_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 1. 当其他诊断编码为Z37时，新生儿出生体重为必填项
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if (!StringUtils.isBlank(diagnose.getPd0101())) {
                if (diagnose.getPd0101().matches("Z37.*") && "O".equals(diagnose.getPdType())) {
                	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90280001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90280001())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-MaternalInjuryInDelivery_ZhongTie17
     * RULE_NAME: 阴道分娩产妇产伤
     * RULE_INTRODUCTION: 其他诊断编码存在Z37时，选择1或2，其他病历划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleMaternalInjuryInDelivery_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        // 1. 当其他诊断编码为Z37时，新生儿出生体重为必填项
        List<MrDiagnose> diagnoseList = medicalRecordQuality.getDiagnose();
        for (MrDiagnose diagnose : diagnoseList) {
            if (!StringUtils.isBlank(diagnose.getPd0101())) {
                if (diagnose.getPd0101().matches("Z37.*") && "O".equals(diagnose.getPdType())) {
                	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90290001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90290001())) {
                        saveViolationInfo(medicalRecordQuality, rule);
                        return;
                    }
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ComplicationsOfOperationAndAnesthesia01_ZhongTie17
     * RULE_NAME: 手术及麻醉并发症
     * RULE_INTRODUCTION: 必填项
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleComplicationsOfOperationAndAnesthesia01_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        if(StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90031001())){
        	saveViolationInfo(medicalRecordQuality, rule);
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ComplicationsOfOperationAndAnesthesia02_ZhongTie17
     * RULE_NAME: 手术及麻醉并发症
     * RULE_INTRODUCTION: 有手术选择1或2，无则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleComplicationsOfOperationAndAnesthesia02_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        List<MrOperation> mrOperationList = medicalRecordQuality.getOperation();
        for (MrOperation mrOperation : mrOperationList) {
            if ("1".equals(mrOperation.getPo1400())) {
            	//1.有 2.无 3.其它
            	if (!"1".equals(medicalRecordQuality.getMrAppendPage().getP90031001()) && !"2".equals(medicalRecordQuality.getMrAppendPage().getP90031001())) {
                    saveViolationInfo(medicalRecordQuality, rule);
                    return;
                }
            }
        }
    }
    /**
     * Annotation:
     * RULE_CODE: RULE-ComplicationsName_ZhongTie17
     * RULE_NAME: 并发症名称
     * RULE_INTRODUCTION: 有写并发症名称，无则划-
     * @Author: qiaoyilong
     * @Date: 2019/1/08 10:36
     */
    private void ruleComplicationsName_ZhongTie17(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule) {
        //1.有 2.无 3.其它
    	if("1".equals(medicalRecordQuality.getMrAppendPage().getP90031001())){
        	if(StringUtils.isBlank(medicalRecordQuality.getMrAppendPage().getP90032000())){
            	saveViolationInfo(medicalRecordQuality, rule);
            }
        }
    }
    
/** ========================== 中铁十七局的 校验规则     end ========================== */
/*******************************************************************其他规则***********************************************************/

    // ========================== 校验规则 END~ ==========================
    
    /**
     * @Description: 保存触犯的质控项
     * @param  
     * @return  
     * @throws
     * @author chenhanlin
     * @date 2018/8/3 9:29
     */
    private void saveViolationInfo(MedicalRecordQuality medicalRecordQuality, MrqDictRules rule){

    	if( !StringUtils.isBlank(medicalRecordQuality.getIpinfo().getPmainIndex()) && !StringUtils.isBlank(rule.getRuleCode()) ){
        	MrqViolation mrqViolation = new MrqViolation();
            mrqViolation.setId(medicalRecordQuality.getIpinfo().getPmainIndex()+"-"+rule.getRuleCode());
            mrqViolation.setPmainIndex(medicalRecordQuality.getIpinfo().getPmainIndex());
            mrqViolation.setScoreCode(rule.getScoreCode());//BASICINFO
            mrqViolation.setWeightCode(rule.getWeightCode());//C
            mrqViolation.setRuleCode(rule.getRuleCode());// RULE-Gender01
            mrqViolation.setRuleScore(rule.getRuleScore());// 0.5
            mrqViolation.setDetailCode(rule.getDetailCode());//BASICINFO-C-Gender          
            medicalRecordQuality.getMrqViolationList().add(mrqViolation);
    	}
    }
    
    /**
     * @Description: 返回两个日期之间相隔的天数 date2-date1 天
     * @param  
     * @return  
     * @throws
     * @author chenhanlin
     * @date 2018/7/28 21:58 
     */
    private int differentDays(Date date1,Date date2){
         if (date1!=null && date2!=null) {
 	        Calendar day1 = Calendar.getInstance();
 	        day1.setTime(date1);
 	        Calendar day2 = Calendar.getInstance();
 	        day2.setTime(date2);
 			int y1 = day1.get(Calendar.YEAR);
 			int y2 = day2.get(Calendar.YEAR);
 			int days = 0;
 			if( y1 != y2 ){//年分不同
 				if(y1 > y2){
 					day2 = (Calendar) day2.clone();
 					do{
 						days = days - day2.getActualMaximum(Calendar.DAY_OF_YEAR);//得到当年的实际天数
 						day2.add(Calendar.YEAR, 1);
 						y2++;
 					}while(y1 != y2);
 				}else{//y1 < y2
 					day1 = (Calendar) day1.clone();
 					do{
 						days = days + day1.getActualMaximum(Calendar.DAY_OF_YEAR);//得到当年的实际天数
 						day1.add(Calendar.YEAR, 1);
 						y1++;
 					}while(y1 != y2);
 				}
 			}
 			days = days + day2.get(Calendar.DAY_OF_YEAR) - day1.get(Calendar.DAY_OF_YEAR);
            return days;
         } else {
            return 0 ;
         }
    }

    private int getAge(Date birthday,Date inDate){
    	 if (birthday==null && inDate == null) {
             return 0 ;
         }
    	 Calendar cal = Calendar.getInstance();
    	 	cal.setTime(inDate);
    	 	int yearNow=cal.get(Calendar.YEAR);
    	 	int monthNow = cal.get(Calendar.MONTH);
         int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
         
         cal.setTime(birthday);
         int yearBirth = cal.get(Calendar.YEAR);
         int monthBirth = cal.get(Calendar.MONTH);
         int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
  
         int age = yearNow - yearBirth;
         if (monthNow <= monthBirth) {
             if (monthNow == monthBirth) {
                 if (dayOfMonthNow < dayOfMonthBirth) age--;
             }else{
                 age--;
             }
    	}
         return age;
    }

    /**
     * @Description: 编码是否为空的判断
     * @param str
     * @return:
     * @Author: chenhanlin
     * @date: 2019/1/28
     */
    private boolean isBlankCode(String str) {
        if(StringUtils.isBlank(str)){
            return true ;
        } else if("unknown".equals(str)) {
            return true ;
        } else {
            return false ;
        }
    }

    /**
     * @Description: 描述是否为空的判断
     * @param str
     * @return:
     * @Author: chenhanlin
     * @date: 2019/1/28
     */
    private boolean isBlankDesc(String str) {
        if(StringUtils.isBlank(str)){
            return true ;
        } else if("未知描述".equals(str)) {
            return true ;
        }  else {
            return false ;
        }
    }

}
